fastify-request-language
v2.0.0
Published
A middleware to attach language to request by parsing Accept-Language header
Downloads
301
Readme
fastify-request-language
Adds language to the Fastify request
object by parsing Accept-Language
HTTP Header.
Requirements
- Node >= 12
- fastify >= 3
Install
npm install fastify-request-language
Usage
const fastify = require('fastify')({
logger: true,
trustProxy: true,
});
fastify.register(require('fastify-request-language'), {
languages: ['en', 'hi'],
});
// Access language in request.language
fastify.get('/', (request, reply) => {
reply.send({ language: request.language });
});