RequestContext
- 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.ResponseContext
- Allows you to send headers, write data, and more, to be sent to the client. To prevent a response from being modified by future handlers, call res.end()
to prevent further writing.bool
: Request handling will end prematurely if you return false
, but it will continue if you return true
.null
: Request handling will continue, unless you closed the response object by calling res.close()
. Some response methods, such as res.redirect()
or res.serialize()
automatically close the response.RequestHandler
: the returned handler will be executed.Stream
: toList
will be called, and then returned.Future
: it will be awaited, and then returned.json.encode
. However, you can change a response's serialization method by setting res.serializer = foo;
. If you want to assign the same serializer to all responses, globally set serializer
on your Angel instance. If you are only returning JSON-compatible Dart objects, like Maps or Lists, you might consider injecting JSON.encode
as a serializer, to improve runtime performance (this is the default in 2.0
).RequestContext
and ResponseContext
. Consult the dependency injection documentation.Map
based on the URI query parameters by calling RequestContext.queryParameters
.