Skip to content

hapi 17 plugin: sets request.id from x-request-id (or custom like x-amzn-trace-id) header

License

Notifications You must be signed in to change notification settings

soxhub/hapi-x-request-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

hapi-x-request-id

hapi.js v17+ plugin: sets request.id from x-request-id (or custom like x-amzn-trace-id) header

Installation

npm install --save hapi-x-request-id

or

yarn add hapi-x-request-id

Usage

let server = new Hapi.Server();
await server.register({
    plugin: require('hapi-x-request-id'),
    options: {
        header: 'x-amzn-trace-id' // optional
    }
});

server.route({
    method: 'GET',
    path: '/',
    handler: (request, h) => {
        // will return request.info.id if the header is not passed
        // request.info.id is hapi's autogenerated request id
        return request.id;
    }
});

License

MIT

About

hapi 17 plugin: sets request.id from x-request-id (or custom like x-amzn-trace-id) header

Resources

License

Stars

Watchers

Forks

Packages

No packages published