import Http = Deno.errors.Http; import {JSONObject} from "./JSON.ts"; export type HttpMethod = "POST" | "GET" | "PUT" | "DELETE"; export type RouteDefinition = { pattern: RegExp; method?: HttpMethod; }; export default class StoccaTreRequest { constructor( public method: HttpMethod, public route: string, public body: JSONObject | null, ) {} match(route: RouteDefinition): RegExpExecArray | false { const patternResult = route.pattern.exec(this.route); if (route.method && route.method !== this.method) { return false; } return patternResult ?? false; } }