Skip to content

ui-router-server / fetch / delegateContext

Function: delegateContext() ​

ts
function delegateContext<K, Decls>(
   request, 
   key, 
   router?
): DelegateContext<K, Decls>;

Defined in: fetch.ts:381

The route a request matched when the fetch adapter delegated it to key's handler: { mount, subpath, delegate, state, params }. Call it with the very Request the handler received (c.req.raw in a Hono route): the context is keyed by that object, so request.clone() or new Request(request) has none. Pass the router to type state and params from its as const routes and to check the request came through it.

Type Parameters ​

Type ParameterDefault type
K extends string-
Decls extends RouteDeclarationRouteDeclaration

Parameters ​

ParameterTypeDescription
requestRequestthe request a delegate handler received
keyKthe delegate key the handler is mapped to
router?ServerRouter<Decls>the router the adapter was built with

Returns ​

DelegateContext<K, Decls>

Throws ​

when the request was not delegated, was delegated to another key, or came through another router