routes

Failing ASP.NET MVC route. Is this a bug or corner case?

谁都会走 提交于 2019-12-02 18:25:41
I have an ASP.NET MVC 3 application where users can post suggestions along the lines of "bla bla would be better if yada yada yada". For the suggestion detail page I have defined a nice SEO friendly route as follows: routes.MapRoute(null, "suggestion/{id}/{it}/would-be-better-if-{if}", new { controller = "suggestion", action = "details" }); As you can see I want the "would be better if" part to be fixed. This route works perfectly for any old suggestion and generates links like suggestion/5/this-site/would-be-better-if-it-had-a-iphone-application , and clicking on the link actually requests

Need a Rails route with a possible period in the :id, but also retain the optional :format

允我心安 提交于 2019-12-02 18:12:55
I have a Rails route that takes stock ticker symbols as the :id feeds/AMZN will return a page for Amazon feeds/AMZN.csv will return a CSV representation of the same data. But I also need to accomodate stocks like VIA.B (Viacom) so that both of these routes work: feeds/VIA.B (html) feeds/VIA.B.csv (csv) Is this possible? How would I set the routing up? Dylan Markow I ran into this while patching the RubyGems API recently (trying to access the flickr.rb using the API ( /api/v1/gems/flickr.rb.json ) was not working). The trick was to supply the route with a regexp to handle the :id parameter, and

Laravel 5 how to validate route parameters?

折月煮酒 提交于 2019-12-02 18:03:17
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(){ Route::get('checkToken/{token}',['as'=>'checkKey','uses'=> 'ServerController@checkToken']); }); Controller namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Http\Requests; class ServerController extends Controller { public function checkToken( \App\Http\Requests\CheckTokenServerRequest $request) // OT: - why I have to set full path

how to handle routes in Docpad

岁酱吖の 提交于 2019-12-02 17:54:46
问题 This should be really obvious but I just cant get my head around it How do I add extra routes in Docpad?? Im looking for the Docpad equivalent to express.js's app.post("*", function(res,req,next){ //Do stuff } As far as I can understand I need to create a plugin module for this? How do I tell Docpad to use my routes? Im guessing it has something to do with the extend-server event, do I put that as parameter in docpad.coffee? How do I pass the req object to my route handler? can I force docpad

rails singular resource still plural?

邮差的信 提交于 2019-12-02 17:54:25
I have a search route which I would like to make singular but when I specify a singular route it still makes plural controller routes, is this how it's supposed to be? resource :search Gives me search POST /search(.:format) {:action=>"create", :controller=>"searches"} new_search GET /search/new(.:format) {:action=>"new", :controller=>"searches"} edit_search GET /search/edit(.:format) {:action=>"edit", :controller=>"searches"} GET /search(.:format) {:action=>"show", :controller=>"searches"} PUT /search(.:format) {:action=>"update", :controller=>"searches"} DELETE /search(.:format) {:action=>

Rail Routes: Controller namespaces with constraints (subdomains)

旧城冷巷雨未停 提交于 2019-12-02 17:41:26
The intention is to create a subdomain to hold all the administrative function (CRUD) and the name of the subdomain is " admin ". The set of controllers responsible are also organized under the namespace of " admin ", i.e. the controllers are under the app/controllers/admin directory . Ideally, the following routes should be admin.mydomain.com/products/ admin.mydomain.com/products/new ... and not admin.mydomain.com/admin/products/ admin.mydomain.com/admin/products/new ... I would like to keep the helpers with the "admin" prefix such as: new_admin_product edit_admin_product My current routing

Compojure routes with different middleware

旧时模样 提交于 2019-12-02 17:16:49
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" [] ("PUBLIC ENDPOINT"))) (defroutes user-routes (GET "/user-endpoint1" [] ("USER ENDPOINT 1")) (GET "/user-endpoint2" [] ("USER ENDPOINT 1"))) (defroutes admin-routes (GET "/admin-endpoint" [] ("ADMIN ENDPOINT"))) (def app (handler/api (routes public-routes (-> user-routes (wrap-basic-authentication user-auth?))))) (-> admin-routes (wrap-basic

Same Rails 4 routes for GET and POST requests

孤人 提交于 2019-12-02 17:16:04
In Rails 3 Match used to point to an action for both "GET" and "POST" and other type of requests. match "user/account" => user#account Now this will point to account action of user's controller for both GET and POST requests. As in Rails 4 "match" has been deprecated, can we create same route for GET and POST in Rails 4? From the match documentation , you can use match as long as you have via : match "user/account" => "user#account", as: :user_account, via: [:get, :post] Edit: Added a as: parameter so that it will be accessible via a url helper. user_account_path or user_account_url in this

Rails Namespace vs. Nested Resource

人走茶凉 提交于 2019-12-02 17:11:49
Let's say my app has two models, Foo and Bar. Foo optionally belongs_to Bar. Right now I can look at a single Foo, or search for a particular Foo, and the FoosController handles all that. My URLS are like: foos/1 and foos/new Sometimes I want to look at a Bar. The BarsController handles that, and I get to it like: bars/1 or bars/1/edit . If I'm looking at a Bar I might want to browse all the Foos that are part of that Bar. So, I'd like to use bars/1/foos/ to look at those Foos. This is pretty straightforward with nested resources, and it looks like this: resources :foo resources :bar do

AngularJS routes + .htacces rewriting + route Parameters = not working [duplicate]

跟風遠走 提交于 2019-12-02 17:00:50
问题 This question already has answers here : $routeParams Hard Refresh not working on server (base tag needed) (2 answers) Closed 5 months ago . This essentially is a repost of this question Since the question wasn't correctly answered. Using a basic set of self explainatory htaccess rewrites RewriteEngine on # Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # Rewrite everything else to index.html to allow html5