๐ Context
A Sunder Context
encapsulates a FetchEvent's Request
object and is used to construct a Response
.
A Context
is created per request, and is referenced in middleware as the receiver, or the ctx identifier, as shown in the following snippet:
Often writing it like this instead makes for cleaner middleware:
#
Context path parametersOften parameters for the request are encoded in the Request
's path. If you use Router middleware these will be extracted for you automatically and put on the ctx.params
object. If you use Typescript you have to type your context according to what your handler requires:
Optional path parameters can also be specified using ?
.