0xAX/weber — pull request #146 by darkofabijan (2014-01-05 19:03:44+00:00)
Title: Resources routing

I set on quest to make Weber resources routing more RESTful. And the easiest way to that is to copy from Rails - http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions :)

Tests are green, but generated routes are far from what is expected. I figured that out by checking routes in test app - https://github.com/darkofabijan/photosapp. Here are routes that I got:

```console
iex(1)> Route.__route__
[[method: "GET", path: "/", controller: Photosapp.Main, action: :index],
[method: "GET", path: "/elixir/photosapp/photos", controller: Photosapp.Photos,
action: :index],
[method: "GET", path: "/elixir/photosapp/photos/new",
controller: Photosapp.Photos, action: :new],
[method: "POST", path: "/elixir/photosapp/photos",
controller: Photosapp.Photos, action: :create],
[method: "GET", path: "/elixir/photosapp/photos/:id",
controller: Photosapp.Photos, action: :show],
[method: "GET", path: "/elixir/photosapp/photos/:id/edit",
controller: Photosapp.Photos, action: :edit],
[method: "PUT", path: "/elixir/photosapp/photos/:id",
controller: Photosapp.Photos, action: :update],
[method: "DELETE", path: "/elixir/photosapp/photos/:id",
controller: Photosapp.Photos, action: :destroy]]
```

Ideally we should get:

```console
[[method: "GET", path: "/", controller: Photosapp.Main, action: :index],
[method: "GET", path: "/photos", controller: Photosapp.Photos,
action: :index],
[method: "GET", path: "/photos/new",
controller: Photosapp.Photos, action: :new],
[method: "POST", path: "/photos",
controller: Photosapp.Photos, action: :create],
[method: "GET", path: "/photos/:id",
controller: Photosapp.Photos, action: :show],
[method: "GET", path: "/photos/:id/edit",
controller: Photosapp.Photos, action: :edit],
[method: "PUT", path: "/photos/:id",
controller: Photosapp.Photos, action: :update],
[method: "DELETE", path: "/photos/:id",
controller: Photosapp.Photos, action: :destroy]]
```

So we probably need better tests for this part. Which also opens the questions of routing Dsl. I guess it would be the best to have Rails like routing (http://guides.rubyonrails.org/routing.html) - https://github.com/darkofabijan/photosapp/blob/ideal-routing/lib/route.ex#L7.

My open source collaboration experience is very limited so sorry if this is too ad-hoc approach. Maybe it's too early for pull-request but I wanted open up a discussion before getting too deep into code.

P.S.
Also sorry for messy PR. I have this line https://github.com/darkofabijan/vim-web-dev/blob/master/vimrc#L34 in my vimrc which removes trailing whitespace. I generally like it but I am open to changing that practice to match others.