Basic Usage
Install
- Create a new application
mix new my_app
- Add maru to your
mix.exsdependencies:
def deps do
[ {:maru, "~> 0.7"} ]
end
- List
:maruas your application dependencies:
def application do
[ applications: [:maru] ]
end
Basic Router
defmodule MyAPP.Router.Homepage do
use Maru.Router
get do
%{ hello: :world }
end
end
defmodule MyAPP.API do
use Maru.Router
mount MyAPP.Router.Homepage
rescue_from :all do
status 500
"Server Error"
end
end
Config
config :maru, MyAPP.API,
http: [port: 8880]
Run server
$ mix deps.get
$ iex -S mix
Erlang/OTP 17 [erts-6.4] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.0.4) - press Ctrl+C to exit (type h() ENTER for help)
17:42:17.691 [info] Running Elixir.API with Cowboy on http://127.0.0.1:8880
iex(1)>
$ curl 127.0.0.1:8880
{"hello":"world"}
Generate router documents
MIX_ENV=dev is required for generating docs.
$ MIX_ENV=dev mix maru.routers
Updated less than a minute ago
