By default, controller actions in your Sails app will be inaccessible to users until you bind them to a route in your
config/routes.js file. When you bind a route, you specify a URL that users can access the action at, along with options like CORS security settings.
To bind a route to an action in the
config/routes.js file, you can use the HTTP verb and path (i.e. the route address) as the key, and the action identity as the value (i.e. the route target).
For example, the following manual route will cause your app to trigger the
make action in
api/controllers/SandwichController.js whenever it receives a POST request to
'POST /make/a/sandwich': 'SandwichController.make'
If you’re using standalone actions, so that you had an
api/controllers/sandwich/make.js file, a more intuitive syntax exists which uses the path to the action (relative to
'POST /make/a/sandwich': 'sandwich/make'
For a full discussion of routing, please see the routes documentation.
Sails can also automatically bind routes to your controller actions so that a
GET request to
/:actionIdentity will trigger the action. This is called blueprint action routing, and it can be activated by setting
true in the
config/blueprints.js file. For example, with blueprint action routing turned on, a
signup action saved in
api/controllers/user/signup.js would be bound to a
/user/signup route. See the blueprints documentation for more information about Sails’ automatic route binding.