Readonly
methodChain this condition with another condition
Condition to chain with
New condition that applies if both conditions apply
Check if the condition applies to a request (used for routing) (parses the request itself, so use ContextCondition#parse for performance reasons)
Request to check
Whether the condition applies to the request
Use #parse().applies
instead (For performance reasons, as this method parses the request itself and subRequest again)
Chain this condition with another condition (used for sub-routing)
Check if the condition is equal to another condition
Condition to check
Whether the conditions are equal
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)
const condition = new ContextConditionPath("/api/:id");
const info = condition.info(); // { path: "/api/:id" , method: undefined, path2: undefined }
const condition = new ContextConditionAnd([
new ContextConditionPath("/api/:id"),
new ContextConditionMethod("GET"),
]);
const info = condition.info(); // { path: "/api/:id" , method: "GET", path2: undefined }
Get info about the condition (used for collecting info about conditions and squashing them together)
const condition = new ContextConditionPath("/api/:id");
const info = condition.infoJson(); // { path: "/api/:id" , method: undefined, path2: undefined }
Parse the condition (used for routing and sub-routing)
Request to parse
Result of the parsing
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" } }
Check if the condition applies to a request (used for routing) (parses the request itself, so use ContextCondition#parse for performance reasons)
Request to check
Parameters of the condition
Use #parse().parameters
instead (For performance reasons, as this method parses the request itself and appliesTo again)
Get info about the condition (used for collecting info about conditions and squashing them together)
const condition = new ContextConditionPath("/api/:id");
const info = condition.toJson(); // { type: "path", path: "/api/:id" }
Generated using TypeDoc
Condition for Context used for routing and sub-routing