Handler

API ReferenceNetworkingHandler

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


constructor()

Parameters
  • options — Object

Source


method

Type
String

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

Source


uri

Type
Networking.Uri

This property is compared with the request uri.

Source


schema

Type
Schema
Default
null

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

Source


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


exec()

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

Executes the handler, that is:

  • compares the uri with the request,
  • validates the request uri with the schema,
  • calls the handler callback.

It's internally called by the createRequest().

Source


toString()

Returns
String

Returns a string describing the handler.

"get /users/{name}"

Source

results matching ""

    No results matching ""