Skip to content

Accessing CallContext from handlers #7

Description

@SegaraRai

CallContext, which is the argument of the handler created by createCall, can have additional properties, but those properties are not passed to the actual handler (such as h3 app) and are not accessible.

Cloudflare Workers, for example, may need access to event and I want a way to access this.
https://github.com/unjs/nitro/blob/v0.4.4/src/runtime/entries/cloudflare.ts#L26

One suggested solution is to add context prop to req.
(req as any)._callContext = context, or (req as any)[symCallContext] = context (using symbol)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions