sugar-framework/sugar — pull request #19 by slogsdon (2014-02-08 06:08:18+00:00)
Title: adding resource router macro. closes #12

```elixir
resource "/path", Controller
```

expands to

```elixir
get route, controller, :index
get route <> "/new", controller, :new
post route, controller, :create
get route <> "/:id", controller, :show
get route <> "/:id/edit", controller, :edit
put route <> "/:id", controller, :update
patch route <> "/:id", controller, :patch
delete route <> "/:id", controller, :delete

options route do
{:ok, var!(conn) |> resp(200, "") |> put_resp_header("Allow", "HEAD,GET,POST") |> send_resp}
end
options route <> "/new" do
{:ok, var!(conn) |> resp(200, "") |> put_resp_header("Allow", "HEAD,GET") |> send_resp}
end
options route <> "/:_id" do
{:ok, var!(conn) |> resp(200, "") |> put_resp_header("Allow", "HEAD,GET,PUT,PATCH,DELETE") |> send_resp}
end
options route <> "/:_id/edit" do
{:ok, var!(conn) |> resp(200, "") |> put_resp_header("Allow", "HEAD,GET") |> send_resp}
end
```

this falls back to Plug.Router's options macro. need to make a better wrapper macro for options in Sugar.Router. ideal syntax would be

```elixir
options route, allowed_methods
```