/** * This is a derivative of Julien Schmidt's go implementation in httprouter * https://github.com/julienschmidt/httprouter/blob/v1.3.0/tree.go * * Copyright 2013 Julien Schmidt. All rights reserved. * Use of this source code is governed by a BSD-style license that can be found * at https://github.com/julienschmidt/httprouter/blob/master/LICENSE * * It lacks Trailing Slash Recommendation and Case Insensitive Search features * It has patches as applied in https://github.com/gin-gonic/gin * */ declare const enum SegmentType { Static = 0, Root = 1, Param = 2, CatchAll = 3 } export declare class Router { methods: Record>; on(method: HttpMethod, route: string, handler: T): Router; find(method: string, url: string): { handle: T | null; params: [string, string][]; }; } export declare class TreeNode { private path; private indices; private wildChild; private type; private priority; private children; private handle; constructor(path?: string, indices?: string, wildChild?: boolean, type?: SegmentType, priority?: number, children?: TreeNode[], handle?: T | null); private addChild; /** * adds a node with the given handle to the path. * @param path * @param handle * @returns */ set(path: string, handle: T): TreeNode; /** * Returns the handle registered with the given path. Any found parameters * are added to an array of entries * suitable for `Object.fromEntries` or a `Map` constructor * @param path * @returns */ get(path: string): { handle: T | null; params: [string, string][]; }; private insertChild; private incrementChildPriority; } type SetType = S extends Set ? T : never; export type HttpMethod = SetType; declare const HTTP_METHODS: Set<"ACL" | "BIND" | "CHECKOUT" | "CONNECT" | "COPY" | "DELETE" | "GET" | "HEAD" | "LINK" | "LOCK" | "M-SEARCH" | "MERGE" | "MKACTIVITY" | "MKCALENDAR" | "MKCOL" | "MOVE" | "NOTIFY" | "OPTIONS" | "PATCH" | "POST" | "PRI" | "PROPFIND" | "PROPPATCH" | "PURGE" | "PUT" | "REBIND" | "REPORT" | "SEARCH" | "SOURCE" | "SUBSCRIBE" | "TRACE" | "UNBIND" | "UNLINK" | "UNLOCK" | "UNSUBSCRIBE" | "UPGRADE">; export {};