Closed deman4ik closed 4 years ago
Hi @deman4ik , thanks for getting in contact.
Please see an example below:
'use strict'
// example on how to setup modular routers
// https://github.com/jkyberneees/0http#0http---sequential-default-router
const sequential = require('0http/lib/router/sequential')
const router1 = sequential()
router1.get('/hi/:name', (req, res) => {
res.send('Hello ' + req.params.name)
})
// restana service
const service = require('./../index')({})
service.use('/actions', router1)
service.start()
Then
curl http://localhost:3000/actions/hi/Bill
The major difference from this method to the
newRouter
method in the service instance is the downstream referencing to the errorHandler function.
Great! Thank you
Is there a way to create modular router without creating 'service' instance and calling 'service.newRouter()' first?
Like with express.Router