![]() ![]() OnTimeout(request, reply, done): a function called when a request is timed out and the HTTP socket has been hanged up. OnResponse(request, reply, done): a function called when a response has been sent, so you will not be able to send more data to the client. OnSend(request, reply, payload, done): a function called right before a response is sent, it could also be an array of functions. PreSerialization(request, reply, payload, done): a function called just before the serialization, it could also be an array of functions. PreHandler(request, reply, done): a function called just before the request handler, it could also be an array of functions. PreValidation(request, reply, done): a function called after the shared preValidation hooks, useful if you need to perform authentication at route level for example, it could also be an array of functions. PreParsing(request, reply, done): a function called before parsing the request, it could also be an array of functions. OnRequest(request, reply, done): a function called as soon as a request is received, it could also be an array of functions. If you want a custom HEAD handler without disabling this option, make sure to define it before the GET route.ĪttachValidation: attach validationError to request, if there is a schema validation error, instead of sending the error to the error handler. Defaults to the value of exposeHeadRoutes instance option. response: filter and generate a schema for the response, setting a schema allows us to have 10-20% more throughput.ĮxposeHeadRoute: creates a sibling HEAD route for any GET routes.This can be a complete JSON Schema object, with the property type of object and properties object of parameters, or simply the values of what would be contained in the properties object as shown below. querystring or query: validates the querystring.body: validates the body of the request if it is a POST, PUT, PATCH, TRACE, or SEARCH method.They need to be in JSON Schema format, check here for more info. Schema: an object containing the schemas for the request and response. Url: the path of the URL to match this route (alias: path). Method: currently it supports 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT', 'OPTIONS', 'SEARCH', 'TRACE', 'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'LOCK' and 'UNLOCK'. Handling of / route inside prefixed plugins.You have two ways to declare a route with Fastify: the shorthand method and the full declaration. The route methods will configure the endpoints of your application. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |