handle method

void handle(
  1. HttpRequest request
)

Handles an incoming HttpRequest by running global middleware, then dispatching to the router.

This is the main entry point for HTTP request processing.

HttpServer.bind('0.0.0.0', 8080).then((server) {
  server.listen(kernel.handle);
});

Implementation

void handle(HttpRequest request) async {
  await Session.init(request);


  // Buffer the request body to prevent "stream has already been listened to" errors.
  // This allows multiple components (CSRF, Logging, Controllers) to read the body.
  try {
    await request.form().buffer();
  } catch (e) {
    print("Error buffering request body: $e");
  }

  _runMiddleware(request, 0);
}