routes

When user is not logged in redirect to login. Reactjs [duplicate]

时间秒杀一切 提交于 2019-12-02 16:40:13
This question already has an answer here: How to implement authenticated routes in React Router 4? 12 answers My App looks like: class App extends Component { render() { <Router> <div> <Route exact path='/login' component={Login} /> <Route exact path='/game' component={GameContainer} /> <Route exact path='/chat' component={ChatContainer} /> <Route exact path='/info' component={InfoContainer} /> </div> </Router> } If the user visits a page under /game and is not logged in, I want to redirect them to the login page. How to do it an elegant way in all routers? See this answer https:/

NodeJS Express - separate routes on two ports

删除回忆录丶 提交于 2019-12-02 16:38:52
I have an express server, and while building it created several "helper" functions on their own routes. I'd like those routes to be accessed on a different port. Is there anyway to do this in express? In the code below, the "/factory" route (and other functionality) would be on one port, and the helper routes of "/killallthings", "/listallthings", and "/killserver" would be on a separate port. Here is a simplified version of the code: var express = require('express'); var things = []; var app = express(); var port = 8080; app.post('/factory/', function(req, res) { //Create a thing and add it

No route matches missing required keys: [:id]

隐身守侯 提交于 2019-12-02 16:34:15
I'm new at Rails and I've seem similar problems, but I can't solve mine. My routes: resources :users do resources :items end My models: class Item < ActiveRecord::Base belongs_to :user end class User < ActiveRecord::Base has_many :items end HTML: <% @items.each do |item| %> <tr> <td><%= item.id %></td> <td><%= item.code %></td> <td><%= item.name %></td> <td><%= item.quantity %></td> <td><%= link_to "Edit", edit_user_item_path(item) %></td> <---- error And I'm getting the same error: No route matches {:action=>"edit", :controller=>"items", :user_id=>#<Item id: 1, user_id: 1, code: "123", name:

Rails Routing (root :to => …)

元气小坏坏 提交于 2019-12-02 16:33:14
I know how to set the routes root of my rails app to a controller and an action. But how to add an id? /pages/show/1 should be the root. How do I set this? Had this same problem and this worked for me: root :to => "pages#show", :id => '1' Brian Petro As of Rails 4.0 , you can declare the root route like this: root 'controller#action' Matthew's solution works, but I think it is more readable to fetch the object. For example, let's say you want to root to the Page#show action for the page with the name "landing". This is a bit more readable: root :to => "pages#show", :id => Page.find_by_name(

Express.js or angular for handling routes in a MEAN application?

删除回忆录丶 提交于 2019-12-02 15:36:22
I am totally new to everything Nodejs/express/angular, and I just ran into a question that bothers me. When you have a MEAN stack, it seems that routes can be handled by both Express.js and Angular . Angular : For instance, if I define a route in Angular, I can do it like this: var app = angular.module("app", []).config(function($routeProvider) { $routeProvider.when('/login', { templateUrl: '/templates/login.html', controller: 'LoginController' }); $routeProvider.when('/front', { templateUrl: '/templates/front.html', controller: 'FrontController' }); $routeProvider.otherwise({redirectTo: '

Route to static file in Play! 2.0

折月煮酒 提交于 2019-12-02 15:32:52
I'm trying to make a route to a specific static file but everything I'm trying ends with an error. I've made 3 different attempts: 1. GET /file staticFile:/public/html/file.html The error I get: Compilation error string matching regex `\z' expected but `:' found 2. GET /file controllers.Assets.at(path="/public/html", "file.html") The error I get: Compilation error Identifier expected 3. GET /file controllers.Assets.at(path="/public/html", file="file.html") The error I get: (and this is the weirdest) Compilation error not enough arguments for method at: (path: String, file: String)play.api.mvc

How to store routes in separate files when using Hapi?

本小妞迷上赌 提交于 2019-12-02 14:17:20
All of the Hapi examples (and similar in Express) shows routes are defined in the starting file: var Hapi = require('hapi'); var server = new Hapi.Server(); server.connection({ port: 8000 }); server.route({ method: 'GET', path: '/', handler: function (request, reply) { reply('Hello, world!'); } }); server.route({ method: 'GET', path: '/{name}', handler: function (request, reply) { reply('Hello, ' + encodeURIComponent(request.params.name) + '!'); } }); server.start(function () { console.log('Server running at:', server.info.uri); }); However, it's not hard to image how large this file can grow

How to remove route on overrided module?

与世无争的帅哥 提交于 2019-12-02 13:17:18
I added zfcUser module to my project via Composer and overrided it in the module ZfcUserOverride . I want trailing slash work, so I added route in overrided module. zfcUserOverride file module.config.php contents below: <?php $config = array( 'view_manager' => array( 'template_path_stack' => array( 'zfcuser' => __DIR__ . '/../view', ), ), 'controllers' => array( 'invokables' => array( 'zfcuser' => 'ZfcUserOverride\Controller\UserController', ), ) ); $config['router']['routes']['zfcuser']['child_routes']['trailing_slash'] = array( 'type' => 'Literal', 'options' => array( 'route' => '/',

How can I create the Route in Kohana 3.2 for this directory structure: /application/my_use_case/classes/

心不动则不痛 提交于 2019-12-02 12:09:27
I'm using Kohana 3.2 and I need to create the directory structure below for my application. For that, I'm using the Route below, but I'm doing something wrong yet. "Settings" is my use case that I'm developing. <?php Route::set('global', '<directory>(/<controller>(/<action>))', array('directory' => 'settings')) ->defaults(array( 'directory' => 'settings', 'controller' => 'settings', 'action' => 'index', )); ?> So, this is my directory structure for "Settings" use case: - ..\application\settings\classes\controller\settings.php - ..\application\settings\classes\model\settings.php - ..

Periods not allowed in CodeIgniter URI?

放肆的年华 提交于 2019-12-02 12:05:27
So after reading this question on API versioning, I decided to prefix all my routes with a version number: http://localhost/api/1.0/user/login But when I throw an exception within Exceptions Core, it says that the route is: 10/UserControll... I've tried escaping the period, but this did not work. Can anyone replicate this problem and think of a possible solution for it? This is the route I am using for the above: $route['1.0/user/(:any)'] = '1.0/UserController/$1'; These are my permitted URI chars: $config['permitted_uri_chars'] = 'a-z 0-9~%\.:_\-'; Open libraries/Input.php (system/core/Input