Skip to content

Routing Scope and Through parameters to routes.#35

Merged
eliasjpr merged 1 commit intomasterfrom
elias/ch40/route-scopes
May 4, 2017
Merged

Routing Scope and Through parameters to routes.#35
eliasjpr merged 1 commit intomasterfrom
elias/ch40/route-scopes

Conversation

@eliasjpr
Copy link
Copy Markdown
Contributor

@eliasjpr eliasjpr commented May 4, 2017

Routing Scope and Through parameters to routes.

Issue: Routing Scopes [ch40]

Requirements

Scopes are a way to group routes under a common path prefix and scoped
set of plug middleware. We might want to do this for admin
functionality, APIs, and especially for versioned APIs. Let's say we
have user generated reviews on a site, and that those reviews first need
to be approved by an admin. The semantics of these resources are quite
different, and they might not share the same controller. Scopes enable
us to segregate these routes.

Description of the Change

Overloaded the router.draw method to receive a valve and through
attributes. With these 2 attributes routes can now be defined as follow.

routes :web, "/v2" do
    get "/hello", HelloController, :index
    get "/hello/:planet", HelloController, :world
    get "/hello/template", HelloController, :template
end

Why Should This Be In Core?

  • This allows defining scopes for routes which are important for APIs versioning
  • Allows for a cleaner definition for routes.

Benefits

  • No longer have to append the pipeline at the end of the route definition. get "/hello", HelloController, :index, :web
  • When serving static files the scope follows a folder path for instance

Issue: (Routing Scopes [ch40] )[https://app.clubhouse.io/amber/story/40/route-scopes]

Scopes are a way to group routes under a common path prefix and scoped
set of plug middleware. We might want to do this for admin
functionality, APIs, and especially for versioned APIs. Let's say we
have user generated reviews on a site, and that those reviews first need
to be approved by an admin. The semantics of these resources are quite
different, and they might not share the same controller. Scopes enable
us to segregate these routes.

Overloaded the router.draw method to receive a valve and through
attributes.

This allows to define scopes for routes and allows for cleaner
definition of routes.
Copy link
Copy Markdown
Member

@elorest elorest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Sorry it took so long.

@eliasjpr eliasjpr requested review from bew, fridgerator and phoffer May 4, 2017 03:36
Copy link
Copy Markdown
Contributor

@fridgerator fridgerator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@eliasjpr eliasjpr merged commit daa5688 into master May 4, 2017
This was referenced May 20, 2017
@eliasjpr eliasjpr deleted the elias/ch40/route-scopes branch May 20, 2017 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants