routing

Symfony2 how to allow slug with dashes in routes regex?

自作多情 提交于 2019-12-18 03:56:25
问题 My route (slug contains dashes!): region: pattern: /regione/{slug}-{id} defaults: { _controller: SWAItaliaInCifreBundle:Default:region } In Twig template: {% for r in regions %} <a href='{{ path('region', { 'slug':r.slug, 'id':r.id }) }}'>{{ r.name }}</a> {% endfor %} I'm getting an error about regular expression matching. Question : why Symfony2 does not permit dashes in url? How can i specify that my route contains dashes (and it's perfectly fine)? An exception has been thrown during the

How to make IRouteConstraint filter route

筅森魡賤 提交于 2019-12-18 02:18:05
问题 I wrote a custom route constraint, but its filter just doesn't get recognized. Does anyone have an example working use of IRouteConstraint ? Also, note to developers: I get double display of the form on my android. Something must be wrong with the partial rendering? 回答1: Here's a simple constraint that looks up an article slug in a fictional repository: public class SlugRouteConstraint : IRouteConstraint { private readonly ISlugRepository slugRepository = new SlugRepository(); public bool

How do I make a Catch-All Route in Laravel

∥☆過路亽.° 提交于 2019-12-18 01:34:19
问题 I need a laravel routes.php entry that will catch all traffic to a specific domain.com/premium-section of the site so that I can prompt people to become members before accessing the premium content. 回答1: You could also catch 'all' by using a regex on the parameter. Route::group(['prefix' => 'premium-section'], function () { // other routes ... Route::get('{any}', function ($any) { ... })->where('any', '.*'); }); Also can catch the whole group if no routes are defined with an optional param.

Can someone explain asp.net routing syntax to me?

一曲冷凌霜 提交于 2019-12-17 22:58:13
问题 I am dealing with this code in a Web Forms scenario: public static void RegisterRoutes(RouteCollection routes) { Route r = new Route("{*url}", new MyRouteHandler()); routes.Add(r); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.gif/{*pathInfo}"); } Firstly, can anyone tell me where the defintion of {*pathInfo} is? http://msdn.microsoft.com/en-us/library/cc668201.aspx#url_patterns doesn't really define it. Does: routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

Custom Error Pages in Rails?

自作多情 提交于 2019-12-17 22:32:26
问题 I need to implement a custom error page in my rails application that allows me to use erb. I've been following this tutorial (http://blog.tommilewski.net/2009/05/custom-error-pages-in-rails/) and I cannot get it to work locally (or remotely). I am running Rails 2.3.5 Here's the gist of the approach. 1) in the 'application_controller', I over ride the "render_optional_error_file(status_code)" method, and set the visibility to "protected", like this. protected def render_optional_error_file

Angular2 get url query parameters

你说的曾经没有我的故事 提交于 2019-12-17 22:22:42
问题 I'm setting up a Facebook registration for my Angular2 web app. Once the application accepted via Facebook (after being redirected to the Facebook authorization page), it redirect to my webapp with the token and code as url params: http://localhost:55976/?#access_token=MY_ACCESS_TOKEN&code=MY_CODE But once the page is loaded, the params are removed. The url become: http://localhost:55976/ How can I extract the parameters (access_token and code) before they are removed? My routing

Creating routes with an optional path prefix

给你一囗甜甜゛ 提交于 2019-12-17 21:52:32
问题 How can I go about making my routes recognise an optional prefix parameter as follows: /*lang/controller/id In that the lang part is optional, and has a default value if it's not specified in the URL: /en/posts/1 => lang = en /fr/posts/1 => lang = fr /posts/1 => lang = en EDIT Ideally, I'm looking to do this across many controllers and actions by mapping a namespace: map.namespace "*lang" do |lang| lang.resources :posts lang.resources :stories end 回答1: OK, I've managed to sort out this

How do I do geocoding and routing with OpenStreetMap? [closed]

别等时光非礼了梦想. 提交于 2019-12-17 21:49:57
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Because Google Maps API is not available in Israel (see here) I want to use OpenStreetMap. I'm confused by all the different ways to do geocoding, i.e. finding lat,long for an address. I'm also looking for the best way to do routing, i.e. display a route between two locations, using OSM. I'm looking for

Redirect (301) one route to another from routing.yml in Symfony2

十年热恋 提交于 2019-12-17 21:48:13
问题 I know this is probably trivial, but I couldn't find anything on the web or in the Symfony2 reference. How do I redirect one route to another from routing.yml (with 301 status code)? I'm looking for something like this: SomeRoute: pattern: /someroute defaults: { _controller: SomeBundle:Controller:action } AnotherRoute: pattern: /anotherroute defaults: { _redirect: {route: SomeRoute, status: 301} } I could create a controller, but it seems overkill, since I don't have any parameters (and it

How to implement “short” nested vanity urls in rails?

时光毁灭记忆、已成空白 提交于 2019-12-17 20:46:40
问题 I understand how to create a vanity URL in Rails in order to translate http://mysite.com/forum/1 into http://mysite.com/some-forum-name But I'd like to take it a step further and get the following working (if it is possible at all): Instead of: http://mysite.com/forum/1/board/99/thread/321 I'd like in the first step to get to something like this: http://mysite.com/1/99/321 and ultimately have it like http://mysite.com/some-forum-name/some-board-name/this-is-the-thread-subject . Is this