Skip to content

JSONP support #451

@pksunkara

Description

@pksunkara
var Hapi = require('hapi');

// Create a server with a host and port
var server = new Hapi.Server('localhost', 8000);

// Define the route
var hello = function (request) {
    request.reply({ greeting: 'hello world' });
};

// Add the route
server.addRoute({
    method: 'GET',
    path: '/hello',
    handler: hello
});

// Start the server
server.start();

With jsonp support, if the user hits http://localhost:8000/hello?jsonp=nice, the server responds with

nice({ greeting: 'hello world' });

This jsonp support can be switched off with config during server instantiating.

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions