Implements

Constructors

Properties

Methods

Constructors

Properties

Handles an incoming HTTP request and returns a response.

The standard Request object representing the incoming HTTP request.

The response to send back, either synchronously or as a promise.

Methods

  • Registers one or more type-safe middleware handlers that apply to multiple routes.

    Use this method for cross-cutting concerns like authentication, logging, or rate-limiting that should run across several endpoints.

    For middleware that should run on only one endpoint, set the IHttpEndpoint.middlewares property directly on that endpoint definition instead — this scopes the middleware to that route alone and prevents it from affecting other endpoints.

    Parameters

    Returns IHttpRouterBase

    The router instance for chaining.

  • Adapts a Winter TC request handler into an HttpHandlerFn that can be used with HttpRouter.endpoint().

    Winter TC handlers use the standard fetch signature (request: Request) => Promise<Response>, while HttpRouter endpoint handlers receive the richer HttpHandlerArgs interface. This method bridges the two by passing args.req.webReq (the underlying Web API Request) to the Winter TC handler and converting the returned Response back via args.fromWebRes().

    Parameters

    • winterTcHandler: WinterTcRequestHandler

      A Winter TC handler function conforming to WinterTcRequestHandler ((request: Request) => Promise<Response>).

    Returns HttpHandlerFn

    An HttpHandlerFn suitable for use in router.endpoint().

    const winterHandler: WinterTcRequestHandler = async (request) => {
    const url = new URL(request.url);
    if (url.pathname === "/health") {
    return new Response("OK", { status: 200 });
    }
    return fetch(request);
    };

    router.endpoint({
    url: "/proxy/*",
    method: ["GET"],
    handler: HttpRouter.fromWinterTcHandler(winterHandler),
    });