routes

A route to serve static assets (like .jpgs, etc?)

China☆狼群 提交于 2019-12-02 20:51:34
I've worked my way through a number of interesting routing problems - turning a request URL into a hash, etc., but just out of curiosity, is there a way to tell the routing system that you want anything that comes under a certain url subpath to be served literally - without going through a controller? For instance, if I have /home/me/public_html/rails_proj/images/foo.jpg, and .../rails_proj/images/other/bar.jpg, can I insert a route that says "anything under images should just be served as an object of the default mime type?" Might be interesting. If you put the "images" directory into the

Angular 2 Activatedroute params not working in Service or outside <router-outlet>

拥有回忆 提交于 2019-12-02 20:20:16
I have a very strange problem: index.html <navigation-menu *ngIf="isLoggedIn"></navigation-menu> <div class="content-wrapper" [ngClass]="{'fullContent' : !isLoggedIn}"> <section class="content"> <router-outlet></router-outlet> </section> </div> The navigation-menu is a component for the nav menu. In router-outlet content there is a component called "assets". What I did in asset component: import { ActivatedRoute}from "@angular/router"; constructor(private route: ActivatedRoute){} public ngOnInit(): void { this.route.params.subscribe(params => { const id = params["id"]; } This works and I get

In express how do I redirect a user to an external url?

一世执手 提交于 2019-12-02 20:08:02
I have a payment system using node.js and braintree, when the payment is successful I want to send the user to the back end. My back end is setup elsewhere. I have tried res.writeHead(301, {Location: 'http://app.example.io'} ); res.end(); So window.location is obviously not available. I cant think of any ways to redirect a user? TheIronDeveloper You can do res.redirect('https://app.example.io'); Express docs: https://expressjs.com/en/api.html#res.redirect The selected answer did not work for me. It was redirecting me to: locahost:8080/www.google.com - which is nonsense. 301 Moved Permanently

How to rename REST routes in URL?

烂漫一生 提交于 2019-12-02 20:05:25
Give that I have a model called Apple and it has a controller ApplesController , the routes are: resources :apples apples GET /apples (.:format) {:controller=>"apples ", :action=>"index"} new_apple GET /apples /new(.:format) {:controller=>"apples ", :action=>"new"} edit_apple GET /apples /:id/edit(.:format) {:controller=>"apples ", :action=>"edit"} I would like to keep all code the same, except that in URLs, the "apple" would be replaced by "car". So, the URL /apples/new would become /cars/new . Is there some way to do this while not touching any other code in the app? (i.e. internally in the

How to rename the default identifier param “id” in Rails' map.resources()?

有些话、适合烂在心里 提交于 2019-12-02 19:32:56
I like all the default routes that are generated by Rail's map.resources . But, there are cases where I would like to use a non-numeric identifier in my routes. For example, If have a nested route consist of users and their articles, a standard route could be written as such: map.resources :users, :has_many => [:articles] # => e.g. '/users/:id/articles/:id' However, there are many advantages / reasons not to use the default numerical identifier generated by Rails. Is there a way to replace the default :id params to another canonical identifier of my choice without resulting to writing custom

How to force Laravel Project to use HTTPS for all routes?

南楼画角 提交于 2019-12-02 19:03:57
I am working on a project that requires a secure connection. I can set the route, uri, asset to use 'https' via: Route::get('order/details/{id}', ['uses' => 'OrderController@details', 'as' => 'order.details', 'https']); url($language.'/index', [], true) asset('css/bootstrap.min.css', true) But setting the parameters all the time seems tiring. Is there a way to force all routes to generate HTTPS links? Mirceac21 You can set 'url' => 'https://youDomain.com' in config/app.php or you could use a middleware class Laravel 5 - redirect to HTTPS . Here are several ways. Choose most convenient.

Backbone.js route optional parameter

╄→尐↘猪︶ㄣ 提交于 2019-12-02 19:01:49
Is it possible to have optional parameters in a Backbone.js route? e.g this: routes: "search/[:query]": "searchIndex" instead of: routes: "search/": "searchIndex" "search/:query": "searchIndex" As of Backbone 0.9.9, you can add optional paramaters with parentheses. For example in your routes object you can define an optional route part like this: routes: { "organize(/:action)": "displayOrganize" } Now the url path will match /#organize and routes like /#organize/create . Keep in mind that if you need routes like /#organize/ (with a trailing slash) to be recognized, you can do: routes: {

Redirecting issues when user cannot sign in using Devise

旧时模样 提交于 2019-12-02 18:45:38
In my application I authenticate users using Devise and I noticed that you can change the page that one is redirected to if the sign in fails. On the wiki I found the following example: class CustomFailure < Devise::FailureApp def redirect_url new_user_session_url(:subdomain => 'secure') end # You need to override respond to eliminate recall def respond if http_auth? http_auth else redirect end end end Following this example I created my own CustomFailure class(custom_failure.rb) and placed in the helper folder (not sure where to put it). This is the following class I created: class

Laravel route url changing after app()->handle() function

ぃ、小莉子 提交于 2019-12-02 18:33:08
问题 I'm accessing an api in my own project, but now I'm having problem with the route function, after dispatching the request with app()->handle($req) , route function generate a different url $req = Request::create('/api/auth/login', 'POST', [ "user" => $request->user, "password" => $request->password, ]); $redirect = route('home'); // http://127.0.0.1:8000/home $res = app()->handle($req); $redirect = route('home'); // http://localhost/home What did I miss? 回答1: Request::create() is a method

Dynamic routing Apache Camel

雨燕双飞 提交于 2019-12-02 18:31:48
问题 Is there some solution to create a camel route dynamically, in time execution? In a common way, we explicitly define a camel route as: from("direct:a") .to("direct:b"); However, I want to create some routes in time execution when be required. For example, from a property file, the application will read the properties and create the routes using the properties. I'll have the code: from({property1}) .to({property2}); If exists one more property file the application must create dynamically