New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grouping routes for similar functions into seperate files #21
Comments
This is totally possible and works much the same as express. The big difference is that you can nest subrouters into any rill method (at, get, put, post, etc) and that you have to use a catch all path like '/animals/*'. Your above example would look like this: index.js app.at('/animals/*', require('./animals')) animals.js var rill = require('rill')
, router = rill()
// Domestic animals page
router.get('/domestic', function(rctx) {
ctx.res.body = 'Cow, Horse, Sheep'
})
// Wild animals page
router.get('/wild', function(ctx) {
ctx.res.body = 'Wolf, Fox, Eagle'
})
module.exports = router Feel free to ask more questions if this unclear. |
@DylanPiercey So they can't be exactly the same then. |
@imolorhe what do you mean? I never claimed for it to be exactly the same as express 😜. Rill itself more similar to koa than express but ultimately it's different than both because it is optimized for both the browser and the server. |
@DylanPiercey Okay. How about passing multiple middlewares to |
Hello,
Is it possible to group routes into seperate files the same way you would do it in express?
In express, you could just do:
app.use('/animals', require('./animals'))
and inside
animal.js
, you could have:Such that all the routes are preceded with
/animals
. Can this be achieved in rill as well?The text was updated successfully, but these errors were encountered: