padrino/padrino-framework — Issue #747: Josh's major routing changes
Author: nesquena
Created: 2012-01-09 22:19:08+00:00
State: open

Josh has some ideas for some fairly major routing API changes to cleanup the whole controller situation. Below is a list of breaking api changes:

## Basic Named Routes

The new syntax for named routes would be:

```
get :index, "/" do

end

get :show, "/posts/:id/show" do

end
```

with the named route first and the url path second. Standard sinatra syntax is also supported.

## The `with` keyword

```
# DEPRECATED
get :account, :with => :id do
```

would be deprecated in favor of the more explicit:

```get :account, "/:id" do```

## Map Keyword

The `map` would be deprecated:

```
# DEPRECATED
get :account, :map => "account/bar" do
```

and changed to:

```
get :account, "account/bar" do
```

## Controllers

Controllers would still act as a natural grouping for routes and would be prefixed into the route paths:

```
SimpleApp.controllers :admin do
```

would still work (and append "/admin" to all contained routes), this would also work:

```
SimpleApp.controllers :admin, "/bar" do
```

which would change the prefix in a way consistent with the new mapping syntax.

```
SimpleApp.controllers "/admin" do
```

also still works.

## The `parent` keyword

```
# DEPRECATED
SimpleApp.controllers :product, :parent => :user do
```

would be more explicit:

```
SimpleApp.controllers :product, "/user/:user_id/products" do
```

## The `priority` keyword

We would change priority to be for controllers rather than routes, i.e

```get :show, :map => '/*page', :priority => :low do```

becomes

```MyApp.controllers :products, :priority => :low```