Handler

APINetworkingHandler

Represents a callback function called on the request.

Each handler must determine an uri, which is compared with the got request URI.

You should use createHandler() to create a functional handler.

Access it with:

var Networking = require('networking');
var Handler = Networking.Handler;

Source

Handler::constructor(options)

Parameters:
  • options — Object

Source

Handler::method

Type:
String

Describes which type of the request, this handler can handle.

Source

Handler::uri

Type:
Networking.Uri

This property is compared with the request uri.

Source

Handler::schema

Type:
Schema
Default value:
null

Used to determine whether the request uri is valid and can be handled by the handler callback.

Source

Handler::callback

Type:
Function

Function used to handle the request.

It's called with three parameters: Networking.Request, Networking.Response and a next function.

If the next function is called, the next handler is checked.

Source

Handler::exec(request, response, next)

Parameters:
  • request — Networking.Request
  • response — Networking.Response
  • next — Function

Executes the handler, that is:

It's internally called by the createRequest().

Source

Handler::toString()

Returns:
String

Returns a string describing the handler.

"get /users/{name}"

Source