Fake Mirrors
    Preparing search index...

    Class HttpServerRouter

    Represents the http-server router.

    The router acts as root of HTTP server and handles the routing of requests through a middleware chain.

    • get isActive(): boolean

      Checks if the router is active.

      Returns boolean

      true if the router is active, false otherwise.

    • Activates the router, enabling middleware processing.

      Once activated, middleware can be retrieved but not added.

      Returns this

      This router for method chaining.

    • Adds a middleware in the chain.

      Middleware can only be added before the router is activated.

      Parameters

      • name: string

        The unique name for the middleware.

      • handler: HttpServerMiddleware

        The middleware handler function.

      Returns this

      This router for method chaining.

      Error If the router is already active.

      Error If a middleware with the same name already exists.

    • Retrieves a middleware by its index.

      Middleware can only be retrieved after the router is activated.

      Parameters

      • idx: number

        The index position of the middleware.

      Returns [string, HttpServerMiddleware] | undefined

      The middleware tuple with name and handler, or undefined if not found.

      Error If the router is not active.

    • Registers the router as a singleton in the DI container.

      Parameters

      • container: DIContainer

        The DI container to register in.

      Returns void