hapi-xhr

1.0.2 • Public • Published

hapi-xhr

npm version

Add xhr property to a request object of hapi.

install

npm install hapi-xhr

Usage

var Hapi = require('hapi');
var HapiXhr = require("hapi-xhr");

var server = new Hapi.Server();
server.connection({ 
    host: 'localhost', 
    port: 8000 
});

server.register(HapiXhr, function(err) {

  server.route({
    method: 'GET',
    path: '/test',
    handler: function(request, reply) {
      if (request.xhr) {
        return reply({ status: 'xhr' });
      }
      return reply({ status: 'not xhr' });
    }
  });

  server.start(function () {
    console.log('Server running at:', server.info.uri);
  });

});

Readme

Keywords

Package Sidebar

Install

npm i hapi-xhr

Weekly Downloads

1

Version

1.0.2

License

ISC

Last publish

Collaborators

  • bells17