Class ContextConditionMethod

Condition for Context used for routing and sub-routing

Hierarchy

Constructors

Properties

method: Method

Methods

  • Check if the condition is equal to another condition

    Parameters

    Returns boolean

    Whether the conditions are equal

    Example

    const condition = new ContextConditionPath("/api/:id");
    const other = new ContextConditionPath("/api/:id");
    const other2 = new ContextConditionPath("/api/:id2");

    condition.equals(other) // true
    condition.equals(other2) // false
  • Get info about the condition (used for collecting info about conditions and squashing them together)

    Returns ConditionInfo

    Example

    const condition = new ContextConditionPath("/api/:id");
    const info = condition.info(); // { path: "/api/:id" , method: undefined, path2: undefined }

    Example

    const condition = new ContextConditionAnd([
    new ContextConditionPath("/api/:id"),
    new ContextConditionMethod("GET"),
    ]);
    const info = condition.info(); // { path: "/api/:id" , method: "GET", path2: undefined }

    See

    ContextCondition#infoJson

  • Parse the condition (used for routing and sub-routing)

    Parameters

    • req: Request

      Request to parse

    Returns ConditionParseResult

    Result of the parsing

    Example

    const condition = new ContextConditionPath("/api/:id");
    const result = condition.parse({ method: "GET", path: "/api/123", params: {} });

    result.applies // true
    result.parameters() // { id: "123" }
    result.subRequest({ method: "GET", path: "/api/123", params: {} }) // { method: "GET", path: "", params: { id: "123" } }

    See

    ConditionParseResult

Generated using TypeDoc