routes

React Router Redirect drops param

别来无恙 提交于 2019-12-05 14:33:57
问题 I am using the next version of React Router, and it seems to be dropping params. I expect the redirect below to retain the value of channelId , but the to route uses the literal string " :channelId " in the path instead. <Switch> <Route exact path="/" component={Landing} /> <Route path="/channels/:channelId/modes/:modeId" component={Window} /> <Redirect from="/channels/:channelId" to="/channels/:channelId/modes/window" /> </Switch> This looks like a resolved issue, but it's not working. Is

Using a regex to match a substring in a Laravel route

爷,独闯天下 提交于 2019-12-05 14:31:14
My URL is: www.foo.com/some-bar-slug-here/page I can't get a route to catch if the string "bar" is found in the slug shown above: Route::any('{myslug}/page/', array('as'=>'bar-page', 'uses'=>'Controllers\MyBar@index')) ->where('myslug','/bar/'); If I use the regex expression [0-9A-Za-z\-]+ it works, but it doesn't work for /bar/ . Any ideas? I got it working with ^([0-9A-Za-z\-]+)?bar([0-9A-Za-z\-]+)? So the updated route code looks like this: Route::any('{myslug}/page/', array('as'=>'bar-page', 'uses'=>'Controllers\MyBar@index')) ->where('myslug','^([0-9A-Za-z\-]+)?bar([0-9A-Za-z\-]+)?');

How do I create a 'route' in wordpress?

妖精的绣舞 提交于 2019-12-05 14:15:04
问题 For my own sanity I'm trying to create a route for an ajax api that looks something like: /api/<action> I'd like wordpress to handle this route and delegate to the proper action with do_action . Does wordpress give me a hook to implement this? Where's a good spot? 回答1: You have to use add_rewrite_rule Something like: add_action('init', 'theme_functionality_urls'); function theme_functionality_urls() { /* Order section by fb likes */ add_rewrite_rule( '^tus-fotos/mas-votadas/page/(\d)?',

ASP NET Web API Route templates

不羁的心 提交于 2019-12-05 14:14:52
I have an entity named Agency with following apis GET http://localhost:37331/api/agency?start=1&limit=10&status=1 GET http://localhost:37331/api/agency/2 POST http://localhost:37331/api/agency PUT http://localhost:37331/api/agency DELETE http://localhost:37331/api/agency/4 POST http://localhost:37331/api/agency/activate/3 POST http://localhost:37331/api/agency/deactivate/3 GET http://localhost:37331/api/agency/types The route templates I used are config.Routes.MapHttpRoute( name: "ControllerActionIdApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { }, constraints: new { id

Rails - how to handle routes that don't exist (“No route matches [GET]”)?

a 夏天 提交于 2019-12-05 13:30:43
My route looks like match 'about' => 'company#about' When I set to the url http://localhost:3000/aboutttt , I get the error message No route matches [GET] "/aboutttt" I want to give the user better feedback than that. The best solution by my opinion could be redirect the app back, or on the homepage of the app, but exist in routes any way to set default route, when I get the error above? Run your app with the environment set to production and I think you'll find you'll no longer see this message. It's a convenience for debugging while you're developing. There's a setting in config/environments

Routes and subpackages in controllers

梦想与她 提交于 2019-12-05 12:38:07
问题 I'm using Play 2.1 and I'm having some odd problems. I have a subpackage messages in the controllers package with a class i18n.java . My routes file looks like this: GET \ controllers.messages.i18n.index() POST \ controllers.messages.i18n.process() I now have a form with the following action: @helper.form(action = routes.messages.i18n.process()) but this gives me an error: value messages is not a member of object controllers.routes I've used subpackages before in Play 2.0.4 and it worked fine

webapp2 Route to match all other paths

纵然是瞬间 提交于 2019-12-05 12:33:07
I've the following code in my main app. I expect all paths other than the first two to be caught by the last route (/.*). But I get 404 error. What am I missing? import webapp2 from webapp2 import WSGIApplication, Route # ---- main handler class MainPage(webapp2.RequestHandler): def get(self): ret = jinja2render.DoRender(self) return ret routes = [ Route (r'/rpc', handler = 'rpc.RPCHandler'), Route (r'/secured/somesecuredpage', handler = 'secured.securedPageHandler'), Route (r'/.*', handler = MainPage), ] app = WSGIApplication(routes, debug=True) I can change the last route from "/. " to "/<:.

How do you pass multiple arguments to nested route paths in Rails?

折月煮酒 提交于 2019-12-05 09:58:09
I am new to Rails and normally set up a link_to helper for a normal unnested route like so: link_to "Delete", article_path(article.id), method: :delete, data: {confirm: "Are you sure?"} However I am learning about nested routes and it seems I need to provide the path with two arguments for example: link_to "(Delete)", article_comments_path(comment.article_id, comment.id), method: :delete, data:{comfirm: 'Are you sure?'} However this does not seem to work. I have seen that you can format the link_to like this: link_to 'Destroy Comment', [comment.article, comment], method: :delete, data: {

ASP.NET MVC - Where do you put your .js files if you dont want to store them in /Scripts?

纵饮孤独 提交于 2019-12-05 09:51:09
I have a number of .js files that I would like to be stored in the same directories as their views (they're specific to a view - its simply to keep the javascript separate from the view's HTML) However, adding them to the /Views/ControllerName/ directory wont work because when a request is made to the webserver for the .js file: <script type="text/javascript" src="/Views/ControllerName/myscript.js"></script> It would essentially be directed at the 'Views' controller which obviously doesnt exist. Update From what I have read, adding the following IgnoreRoute in the global.asax.cs RegisterRoutes

Is the controller name derived from the class name?

戏子无情 提交于 2019-12-05 09:48:25
This is a newbie question... I am looking at the default asp.net mvc3 project and noticed that there is a controller called: public class AccountController : Controller I looked throughout the code and couldn't find a place that specified AccountController maps to /Account/ for the URL. I discovered that you can change the routing using routes.MapRoute(..) in the Global.asax , but I still don't know where they specified that AccountController maps to /Account/. If it is assumed from the class name, then does that mean all controller classes have to be named xxxxxController? Yes you are right,