Route handler
Last updated
Last updated
[sdks/expressjs/Route handler]
Receives requests on the specified route and dispatches the corresponding response. You may also consider method specific route handlers for easier use. Example:
"my-express-server"@0 received on app ID
"GET"@0 received on method
"/status/"@0 received on route
a client GET request received by express with URL "http://api.mydomain.com/status"
{
"body": "",
"hostname": "api.mydomain.com",
"method": "GET",
"path": "/status",
"protocol": "http",
}@0 sent on request
to other node for processing
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": { status: "OK" }
}@0 received back on response
from processing nodes and sent out to the client
7.
null@0 sent on done
"my-express-server"@0 sent on app ID
Keywords: http, server, express, rest, api, route, request, handler, process
app ID: string
The id of the express instance. Example: "my-express-server"
method: ("GET" or "POST" or "PUT" or "PATCH" or "DELETE")
Receives the method to handle request for. Example: "GET"
route: (string or string[])
Receives the route(s) to handle requests for. Route be specified as exact match (1) or as pattern match (2). Example:
"/status" will just match "/status"
"/s*s" will match "status", "shoes", etc..
response:
Receives the response to be sent out to the client. Example: { "status": 200, "headers": { "content-type": "application/json" }, "body": "Done" }
request:
Forwards the request to be processed.
done: null
Event triggered when the specified action has been executed.
app ID: string
The id of the express instance the action was executed on. Emitted when the action was executed. To be used when chaining multiple actions on the same express instance. Example: "my-express-server"
error: {"error": string}
Sends error information in case the request could not be handled.