uwsjs-fork (forked from uWebSockets.js) v0.0.1 documentation
    Preparing search index...

    Interface HttpRequest

    An HttpRequest is stack allocated and only accessible during the callback invocation.

    interface HttpRequest {
        forEach(cb: (key: string, value: string) => void): void;
        getCaseSensitiveMethod(): string;
        getHeader<T extends RecognizedString = RecognizedString>(
            lowerCaseKey: T,
        ): string;
        getMethod(): string;
        getParameter(index: number | RecognizedString): string | undefined;
        getQuery(): string;
        getQuery(key: string): string | undefined;
        getUrl(): string;
        setYield(_yield: boolean): this;
    }
    Index

    Methods

    • Loops over all headers.

      Parameters

      • cb: (key: string, value: string) => void

      Returns void

    • Returns the HTTP method as-is.

      Returns string

    • Returns the lowercased header value or empty string.

      Type Parameters

      Parameters

      • lowerCaseKey: T

      Returns string

      var server = App()
      server.get("/basic-usage", (res, req)=>{
      console.log(req.getHeader("content-length"));
      res.end("ok");
      })

      type BasicHeaders = {"Content-Type": `${string}/${string}`}
      type lowHeaders = Lowercase<keyof BasicHeaders>
      server.get("/LSP-help", (res, req)=>{
      console.log(req.getHeader<lowHeaders>("content-length"));
      res.end("ok");
      })
    • Returns the lowercased HTTP method, useful for "any" routes.

      Returns string

    • Returns the parsed parameter at index. Corresponds to route. Can also take the name of the parameter.

      Parameters

      Returns string | undefined

    • Returns the raw querystring (the part of URL after ? sign) or empty string.

      Returns string

    • Returns a decoded query parameter value or undefined.

      Parameters

      • key: string

      Returns string | undefined

    • Returns the URL including initial /slash

      Returns string

    • Setting yield to true is to say that this route handler did not handle the route, causing the router to continue looking for a matching route handler, or fail.

      Parameters

      • _yield: boolean

      Returns this