url-routing

Nested routes in express, where a parent route includes a param

旧时模样 提交于 2019-12-06 00:39:24
问题 What is the best way of defining a route hierarchy so that I have a basic URL of /page/:id , and then urls like /page/:id/delete and /page/:id/edit , without having to repeat the /page/:id bit in all the paths? I've tried the following, but the id param isn't available in the sub routes: pageActions = express.Router! pageActions.get "/delete", (request, response) -> request.params.id #undefined app.use "/page/:id", pageActions I can't see any mention of this behaviour in the routing guide,

Processing URL parameters - name value pairs separated by slashes

我们两清 提交于 2019-12-06 00:08:12
I want to have URLs like :- URL 1 - www.projectname/module/search/param/1 URL 2 - www.projectname/param/1/module/search I want a PHP code which takes the above URLs as parameter and returns an array like Array("module" => "search", "param" => 1) (for URL 1) Array("param" => 1, "module" => "search") (for URL 2) So that I can use the result as $_GET in my project. I came to know that it would be better and easier to do this with PHP than with htaccess rewrite rules. If you can help with rewrite rules also please help. There can be any number of parameters. I got this idea from CodeIgniter's URL

AngularJS route parameters with any characters

蹲街弑〆低调 提交于 2019-12-05 22:51:27
问题 I am new to AngularJS, so forgive me if this is obvious, but I am looking for someone who can answer this tricky question. I am implementing an application, and need to pass some parameters to a particular view to display details about a book. Basically I would like to be able to use the following routing expressions: bookApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/catalog', { templateUrl: 'cataloglist.htm', controller: 'catCtrl' }). when('/book/:title/

Symfony2 per-host access control

风流意气都作罢 提交于 2019-12-05 21:47:06
I am trying to implement host routing in Symfony 2.2. I have added the route to app/config/routing.yml, but the security restrictions in app/config/security.yml are redirecting the requests. For example, I have (www.)domain1.com and {subdomain}.domain2.com. I want the security restrictions in security.yml to apply only to {subdomain}.domain2.com (my app), and not to (www.)domain1.com (my home page). How can this be achieved? I am looking for something like this: security: firewalls: home_page: host: (www.)domain1.com security: false You can restrict access by hostname with ACL like this: # app

Custom lithium routing scenario

限于喜欢 提交于 2019-12-05 21:17:08
I've been tasked with rewriting an existing website with large pre-existing link catalog. For argument's sake, let's assume we can't do anything that would change the link catalog. Here's a few examples of the link structure we're working with: An item page would be: www.domain.com/widgets/some-totally-awesome-large-purple-widget A category sub page page would be: www.domain.com/widgets/purple-widgets A category parent page page would be: www.domain.com/widgets/ A custom page may be: www.domain.com/some-random-page The various page types are too numerous to write individual Routers for. Using

CakePHP log in redirect to requested URL

巧了我就是萌 提交于 2019-12-05 20:26:38
When a user clicks a link that requires a log in, we currently redirect them to the log-in page ,but we lose the intended URL. What is the best way to account for that URL and redirect the user to the requested page once logged in? We're using the latest stable version of Cake. Thanks. --Edit-- Its configured like this $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login'); // $this->Auth->autoRedirect = false; $this->Auth->loginRedirect = array('controller' => 'users', 'action' =>

MeteorJS: Routing with Backbone.js

倖福魔咒の 提交于 2019-12-05 20:26:20
I'm trying to implement a router with BackboneJS in my MeteorJS app. When you call the url 'localhost:3000/1' my router stores the id '1' in the session. After that I want to take the id from the session and use it in my query to select an object from my collection. But whenever I try to use a session attribute in my query it fails. So I want to know if there is a better way for routing with MeteorJS and why my query fails. test.js Meteor.subscribe("test"); Test = new Meteor.Collection("test"); Session.set("id", null); Template.hello.test = function () { var avg = 0, total = 0, cursor = Test

how to pass argument in cakephp requestAction?

孤人 提交于 2019-12-05 20:21:43
anyone can tell me, how to pass arguments in cakephp $this->requestAction(...)? requestAction(string $url, array $options) This function calls a controller's action from any location and returns data from the action. The $url passed is a CakePHP-relative URL (/controllername/actionname/params) . To pass extra data to the receiving controller action add to the $options array. # echo $this->requestAction('/articles/view/5'); Try this way: $url = Router::url(array( 'controller' => 'Foo', 'action' => 'edit', 3 )); $this->requestAction($url); 来源: https://stackoverflow.com/questions/4524863/how-to

EmberJS: How to provide a specific URL for a model in ember-data RESTAdapter?

放肆的年华 提交于 2019-12-05 18:50:30
Question 1: If I have a ember-data model called "Company", how do I tell it to hit /businesses and /businesses/:id to retrieve records instead? Is there a way to specify the url for a given model? Even better, like BackboneJS, can I compute a URL for the model at runtime? Questions 2: I have somewhat a unique requirement, my API is organized this way: /api/v1/company/:company_id/form/:form_id/items/:item_id Is there a way to handle this with EmberJS? I understand ember has the DS.hasMany('App.Items') kind of relationships, but they seem to hit the /items/:item_id URL to get the data instead of

ASP.NET MVC - absolute URL to content to be determines from outside controller or view

北慕城南 提交于 2019-12-05 18:12:30
I have some content which is sitting in a path something like this: /Areas/MyUsefulApplication/Content/_awesome_template_bro/Images/MyImage.png Is there a way get a fully qualified absolute URL to that path without being in a controller or view (where url helpers are readily available). You could write an extension method: public static class UrlExtensions { public static Uri GetBaseUrl(this UrlHelper url) { var uri = new Uri( url.RequestContext.HttpContext.Request.Url, url.RequestContext.HttpContext.Request.RawUrl ); var builder = new UriBuilder(uri) { Path = url.RequestContext.HttpContext