Other Default Request Route Default
Request
Route
: { default
: true ; handler
: RequestHandler ; name
?: string } Type declaration default: true Optional name?: string Default Upgrade Route Default
Upgrade
Route
: { default
: true ; handler
: UpgradeHandler ; name
?: string } Type declaration default: true Optional name?: string Http Configs Type declaration Optional no Server?: boolean Http Request Info Http Request Info: { body?: string ; headers: IncomingHttpHeaders ; method: string ; url: string }
Type declaration Optional body?: string headers: IncomingHttpHeaders method: string url: string Request Handler Request
Handler
: ( req
: IncomingMessage , res
: ServerResponse , routingInfo
: RoutingInfo ) => void Type declaration ( req: IncomingMessage , res: ServerResponse , routingInfo: RoutingInfo ) : void Parameters req: IncomingMessage res: ServerResponse Returns void Request Route Request
Route
: { default
?: false ; handler
: RequestHandler ; name
?: string ; path
: string } Type declaration Optional default?: false Optional name?: string path: string Routing Info Routing Info: { matchedPath?: string ; originalPath: string ; trailingPath: string }
Type declaration Optional matched Path?: string original Path: string trailing Path: string Server Listen Options Server Listen Options: ListenOptions
Upgrade Handler Upgrade
Handler
: ( req
: IncomingMessage , socket
: Socket , head
: Buffer , routingInfo
: RoutingInfo ) => void Type declaration ( req: IncomingMessage , socket: Socket , head: Buffer , routingInfo: RoutingInfo ) : void Parameters req: IncomingMessage socket: Socket head: Buffer Returns void Upgrade Route Upgrade
Route
: { default
?: false ; handler
: UpgradeHandler ; name
?: string ; path
: string } Type declaration Optional default?: false Optional name?: string path: string
Http Module
This module provide HTTP listening capability to all the services require it. For example, to serve a webhook for subscribing events from chat platform.
Install
Docs
Check the package reference.
Setup
Use
listenOptions
to set the network options forserver.listen()
.Usage
Provide
Http.RequestRouteList
orHttp.UpgradeRouteList
(for WebSocket) to register RPC style routes. All the requests under the registeredpath
will be received by the handler. You can also usedefault: true
to catch all unmatch requests.