node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

hapi-accept-language

Hapi-accept-language

Build Status NPM version Dependencies

Hapi plugin for automagically parsing the accept-language header, and populating request.pre.language.

Uses the accept-language-parser module under the hood

installation:

npm install hapi-accept-language

usage:

var hapi = require("hapi");
 
var server = new hapi.Server({});
 
server.connection({ port: 3000 });
 
server.route([{
  method: 'GET',
  path: '/my-url',
  config: {
    handler: function(request, reply){
      reply(request.pre.language)
    }
  }
}]);
 
server.register([
  require('hapi-accept-language'),
  ], function(err){
    if(err){
      throw err;
    }
 
    server.start(function(){
      server.log('server started');
    });
});