Skip to content

Request Lifecycle

The request lifecycle is the process that a request goes through in order to be handled by the server. This process is the same for all requests, regardless of the type of request or the route that it is sent to.

The following image summarizes the request lifecycle in Serinus:

Request Lifecycle

The request lifecycle consists of the following steps:

StepDescription
RequestThe client sends a request to the server.
onRequestSerinus receives the request and execute all the onRequest hooks.
RoutingSerinus determines which route to use based on the request URL.
tranformSerinus executes the local transform hook.
parseSerinus executes the ParseSchema of the route if available.
MiddlewaresSerinus executes the middlewares for the route.
beforeHandleSerinus executes the global beforeHandle hook and then the local one.
HandlerSerinus executes the handler for the route.
afterHandleSerinus executes the local afterHandle hook and then the global one.
onResponseSerinus executes the onResponse hooks.
ResponseSerinus sends the response back to the client.

Built with 💙 and Dart 🎯 | One of the 🐤 of Serinus Nest