Requests-and-Responses

    • - Contains vital information about the client requesting a resource, such as request method, request body, IP address, etc. The request object can also be used to pass information from one handler to the next.

    Request handlers can return any Dart value. Return values are handled as follows:

    • If you return a bool: Request handling will end prematurely if you return false, but it will continue if you return true.
    • If you return null: Request handling will continue, unless you closed the response object by calling res.close(). Some response methods, such as or res.serialize() automatically close the response.
    • A RequestHandler: the returned handler will be executed.
    • A Stream: toList will be called, and then returned.
    • A Future: it will be awaited, and then returned.

    Request handlers can take other parameters, instead of just a RequestContext and ResponseContext.Consult the .

    Consult the body parsing documentation to understand how to handle user input.

    If you , be sure to use the lazy alternatives.

    RequestContext

    Next Up…