https://github.com/opentable/hapi-accept-language
plugin to wrap accept-language-parser
https://github.com/opentable/hapi-accept-language
Last synced: 6 months ago
JSON representation
plugin to wrap accept-language-parser
- Host: GitHub
- URL: https://github.com/opentable/hapi-accept-language
- Owner: opentable
- License: mit
- Created: 2015-05-01T09:23:04.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-12-09T18:20:19.000Z (over 8 years ago)
- Last Synced: 2024-11-21T17:47:05.448Z (7 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 4
- Watchers: 17
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#Hapi-accept-language
[](https://travis-ci.org/opentable/hapi-accept-language) [](http://badge.fury.io/js/hapi-accept-language) Hapi plugin for automagically parsing the accept-language header, and populating request.pre.language.
Uses the [accept-language-parser](opentable/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');
});
});```