Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User `constraints` to specify the subdomain name for api portion and can introduce load balancing or increase number of api server needed based on its usage.
- ```ruby
- Rails.application.routes.draw do
- namespace :api, path: '/', constraints: { subdomain: 'api' } do
- resources :users
- end
- end
- ```
- `namespace: api, path: '/'` => the `namespace` by default will put the namespace value in the url (e.g: `localhost:3000/api`), but when specify the `path` is '/', there will be no `/api` in the url.
- This is good because we can group our codes in `api` folder and can use api subdomain.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement