1fastify
2 .get('/', function (request, reply) {
3 // display from view
4 request.req.locals.title = "Hello Wordl";
5 })
1fastify.addHook('onRequest', (req, res, next) => {
2 req.locals = {}
3 next()
4})
5
6fastify.use('/', (req, res, next) => {
7 req.locals.a = 1
8 next()
9})
10
11fastify
12 .get('/', function (request, reply) {
13 reply
14 .send(request.req.locals)
15 })