routes

Node.js & Express routing with parameters

偶尔善良 提交于 2019-12-10 22:28:41
问题 I currently have 2 routes in node.js for an API I am building. They are: app.get('/api/v1/user/:userid', function (req, res) { return res.status(200).json(GetUser()); }); and app.get('/api/v1/user', function (req, res) { return res.status(400).json('UserId expected'); }); As you can see, both routes actually should be combined into one, for example: app.get('/api/v1/user/:userid', function (req, res) { console.log('this should still show if :userid is not populated, but it does not'); if(!req

CakePHP route with regex

假装没事ソ 提交于 2019-12-10 22:08:28
问题 I have a controller setup to accept two vars: /clients/view/var1/var2 And I want to show it as /var1/var2 SO i tried Router::connect('/*', array('admin'=>false, 'controller' => 'clients', 'action' => 'view')); But this stops all other controllers working as /* routes everything All other pages that are on the site are within the admin prefix so basically i need a route that is ignored if the current prefix is admin ! I tried this (regex is from Regular expression to match a line that doesn't

How to add custom verb (http request method ) to rails4

空扰寡人 提交于 2019-12-10 21:03:53
问题 I want to add custom http VERB to rails 4 here is my routes.rb ring "/session/" => "calls#ringing" and I also puts this code to initializers %w(ring busy).each do |method| ActionDispatch::Request::HTTP_METHODS << method.upcase ActionDispatch::Request::HTTP_METHOD_LOOKUP[method.upcase] = method.to_sym end When I try to start application I have this error. undefined method `ring' for #<ActionDispatch::Routing::Mapper:0x000000035c4150> I really need to use this custom verb "RING". 回答1: I fixed

Rails 3 nested routes question

余生颓废 提交于 2019-12-10 20:33:24
问题 I need some help with routes. Here are my current routes. resources :users, :only => [:index, :show, :create, :destroy] do resources :links, :only => [:create, :destroy], :shallow => true, :on => :member end and when I run rake routes I get this root /(.:format) {:controller=>"users", :action=>"index"} user_links POST /users/:user_id/links(.:format) {:action=>"create", :controller=>"links"} link DELETE /links/:id(.:format) {:action=>"destroy", :controller=>"links"} users GET /users(.:format)

no route matches service-worker.js

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 20:29:09
问题 I generated rails application and I got this message out of box. I don't know what service-worker.js is but I assume it can be bundled with some default gem? Started GET "/service-worker.js" for 127.0.0.1 at 2015-07-21 19:48:33 +0200 ActionController::RoutingError (No route matches [GET] "/service-worker.js"): actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' web-console (2.2.1) lib/web_console/middleware.rb:39:in `call' actionpack (4.2.3) lib/action_dispatch

ASP.NET MVC Route Contraints with {ID}-{Slug} Format

天涯浪子 提交于 2019-12-10 19:59:52
问题 I have a route like following, ideally I would like it to match: domain.com/layout/1-slug-is-the-name-of-the-page routes.MapRoute( "Layout", // Route name "layout/{id}-{slug}", // URL with parameters new { controller = "Home", action = "Index"}, new {id = @"\d+$"} ); But when I hit the url, I am keep on getting this exception: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in .... The

Auto-generate routes for scaffolded controller in Rails 4?

[亡魂溺海] 提交于 2019-12-10 19:58:58
问题 I'm trying to get a quick-and-dirty Ajax UI going for an app that already has its data model well in hand - it's basically been managed via rails console so far. Anyway, I thought I would start by auto-generating the missing controller logic that you would get from a rails g scaffold , only instead with rails g scaffold_controller for an existing controller. It created the controller, and the views, and the assets.. but it didn't touch the routes at all! It didn't even try, didn't say

Laravel Exception 405 MethodNotAllowed

社会主义新天地 提交于 2019-12-10 19:52:17
问题 I'm trying to create a new "Airborne" test in my program and getting a 405 MethodNotAllowed Exception. Routes Route::post('/testing/{id}/airbornes/create', [ 'uses' => 'AirborneController@create' ]); Controller public function create(Request $request, $id) { $airborne = new Airborne; $newairborne = $airborne->newAirborne($request, $id); return redirect('/testing/' . $id . '/airbornes/' . $newairborne)->with(['id' => $id, 'airborneid' => $newairborne]); } View <form class="sisform" role="form"

Ember Router not updating url in Chrome and Safari

流过昼夜 提交于 2019-12-10 19:43:07
问题 I have implemented to following in ember.js. The code works up to a certain point. The URL does not change when I enter the application at root url i.e. '/' where it should go to tasks.index and reflect the changes in the url by showing #/tasks. But it behaves correctly when I go to '#/tasks' and shows the message 'hello from index view'. I am using Google Chrome version 19 and ember.js edge. Any help is very much appreciated. App = Em.Application.create({}); App.IndexView = Em.View.extend({

meteor with flow router layout is rendered twice

余生颓废 提交于 2019-12-10 18:54:02
问题 I don't know why but my layout is rendered two times. Here is my index.html: <head> <title>title</title> </head> <body> {{>layout}} </body> Here is my layout: <template name="layout"> {{#if canShow}} {{>Template.dynamic template=content}} {{else}} {{> loginButtons}} {{/if}} </template> So here without route my template is display just one time. Here is my route: FlowRouter.route('/', { action() { BlazeLayout.render("layout", { content: "home" }); } }); But with this route my template is