Questions tagged [routes]

Questions about mapping URLs to Controllers and Actions.

MVC web application (like Ruby on Rails, ASP.NET MVC, etc) uses routes to map an arbitrary URL to a specific controller/action.

For example

http://example.com/foo/bar/23

Might pass an id 23 to controller foo, action bar.

Unusual URLs could also be mapped

Given controller places and intended action list, we can use routes to allow this URL:

http://example.com/my/places
32975 questions
43
votes
1 answer

change the URL without changing the resource name

I'm building a website for a rabbit farmer (let's pretend). This man keeps a close eye on his rabbits, and wants them all categorized. So I built him a RabbitCategoriesController, and added this line to my routes.rb resources…
declan
  • 5,605
  • 3
  • 39
  • 43
43
votes
3 answers

Nesting routes with flutter

I am trying to figure out good architectural solution for following problem: I have following First level routes that can also be referred to as layouts: /onboarding/* -> Shows onboarding layout /dashboard/* -> Shows dashboard layout /overlay/* ->…
Ilja
  • 44,142
  • 92
  • 275
  • 498
43
votes
2 answers

Does angular2 support nested states/routes?

Does angular2 support nested states/routes? for example in a view port there are 2 links and on clicking a specific link it will present a view which with further have more than one link but that are specific to earlier link.
42
votes
3 answers

ASP.NET MVC: url routing vs querystring

I have a page routed like /Comments/Search/3 where i search and display all the comments of the thread "3". I'm adding a sort function (by date, author etc). What is the best way to handle it? /Comments/Search/3/Sort/Author or…
pistacchio
  • 56,889
  • 107
  • 278
  • 420
42
votes
4 answers

angular router navigate then reload

So I want to reload the app after navigating to a specific route .. I use router.navigate to navigate to certain route based on user role and that works fine but I have to reload the page after routing if coming from sign in page (not every time…
Omar Abdelhady
  • 1,528
  • 4
  • 19
  • 31
42
votes
5 answers

Rails: redirect all unknown routes to root_url

Whenever a user hits the wrong page, rails shows 404.html from the public folder. However, I'd like just to redirect the browser to the root page, without showing anything. So I tried globbing, but came to no avail, it still shows the 404 page.…
Albus Dumbledore
  • 12,368
  • 23
  • 64
  • 105
42
votes
10 answers

Laravel 5 how to validate route parameters?

I want to validate the route parameters in the "form request" but don't know how to do it. Below is the code sample, I am trying with: Route // controller Server Route::group(['prefix' => 'server'], function(){ …
42
votes
6 answers

Compojure routes with different middleware

I'm currently writing an API in Clojure using Compojure (and Ring and associated middleware). I'm trying to apply different authentication code depending on the route. Consider the following code: (defroutes public-routes (GET "/public-endpoint"…
user1391110
41
votes
4 answers

Backbone.js route optional parameter

Is it possible to have optional parameters in a Backbone.js route? e.g this: routes: "search/[:query]": "searchIndex" instead of: routes: "search/": "searchIndex" "search/:query": "searchIndex"
TTT
  • 6,505
  • 10
  • 56
  • 82
41
votes
6 answers

ASP.NET MVC - Pass array object as a route value within Html.ActionLink(...)

I have a method that returns an array (string[]) and I'm trying to pass this array of strings into an Action Link so that it will create a query string similar to: /Controller/Action?str=val1&str=val2&str=val3...etc But when I pass new { str =…
Mike
41
votes
5 answers

How do I make a Catch-All Route in Laravel

I need a Laravel routes.php entry that will catch all traffic to a specific example.com/premium-section of the site so that I can prompt people to become members before accessing the premium content.
Tarek Adam
  • 3,387
  • 3
  • 27
  • 52
41
votes
9 answers

Go url parameters mapping

Is there a native way for inplace url parameters in native Go? For Example, if I have a URL: http://localhost:8080/blob/123/test I want to use this URL as /blob/{id}/test. This is not a question about finding go libraries. I am starting with the…
Somesh
  • 1,235
  • 2
  • 13
  • 29
41
votes
5 answers

Rake route Error "Missing :action key on routes definition"

I am getting $ rake routes rake aborted! ArgumentError: Missing :action key on routes definition, please check your routes. /usr/local/rvm/gems/ruby-2.1.2/gems/actionpack-4.1.5/lib/action_dispatch/routing/mapper.rb:243:in…
Tithos
  • 1,191
  • 4
  • 17
  • 40
40
votes
5 answers

What is the difference (if any) between a route and an endpoint in the context of a RESTful API?

Question I have a probably rather simple question, but I'm unable to find an answer with nice explanations: What is the difference (if any) between a route and an endpoint in the context of a RESTful API developed within a Node.js / Express…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
40
votes
7 answers

Rails routes with :name instead of :id url parameters

I have a controller named 'companies' and rather than the urls for each company being denoted with an :id I'd like to have the url use their :name such as: url/company/microsoft instead of url/company/3. In my controller I assumed I would have …
dscher
  • 1,515
  • 2
  • 16
  • 23