Request lifecycle
Web Request lifecycle
Request processing cycle (also it can be called request lifecycle) has next main parts:
- Framework receives request and performs routing to determine controller for request processing.
If required route not exists - framework creates
NotFoundHttpError
and dispatchesRuntimeError
event. RequestReceived
event is being dispatched. If listeners for that event returned response object - framework goes to p.5.- Controller starts.
RequestProcessed
event is being dispatched.ResponseBeforeSend
event is being dispatched.- Framework sends response to user.
RequestTermination
event is being dispatched. Notice:RequestTermination
is dispatched in separate goroutine in order not to delay response sending to user.- If some panic occurs during request processing framework recovers it and dispatches
RuntimeError
.