httpRequestHandler function
this is a class which get matched routes and
pass http request to route middleware and controllers
and response from controllers is passed to httpResponseHandler
Implementation
void httpRequestHandler(HttpRequest req) {
try {
RouteData? route = httpRouteHandler(req);
if (route == null) return;
httpCorsHandler(route.corsEnabled, req);
if (WebSocketTransformer.isUpgradeRequest(req)) {
httpWebSocketHandler(req, route);
return;
}
getDoxRequest(req, route).then((DoxRequest doxReq) {
middlewareAndControllerHandler(doxReq).then((dynamic result) {
httpResponseHandler(result, req);
}).onError((Object? error, StackTrace stackTrace) {
httpErrorHandler(req, error, stackTrace);
});
}).onError((Object? error, StackTrace stackTrace) {
httpErrorHandler(req, error, stackTrace);
});
/// form data do not support isolate or multithread
} catch (error, stackTrace) {
httpErrorHandler(req, error, stackTrace);
}
}