@whi/cf-routing - v0.2.0
    Preparing search index...

    Function handleRoute

    • Wrapper function to handle JSON responses and errors for route handlers

      Supports three return patterns:

      1. Return a Response object directly for full control
      2. Modify this.response (ResponseContext) and return data for the body
      3. Return plain data (current behavior - JSON serialized with defaults)

      Type Parameters

      Parameters

      • worker_router: WorkerRouter<E>
      • handler: (request: Request, env: E, params?: Record<string, string>) => Promise<any>

        The route handler function

      • OptionalresponseContext: ResponseContext

        Optional ResponseContext for customizing response properties

      Returns (request: Request, env: E) => Promise<Response>

      A wrapped handler function that handles JSON responses and errors