core/route

Types

UrlPattern = tuple[route: string, matcher: HandlerAsync,
                   httpMethod: seq[HttpMethod], name: string,
                   middlewares: seq[HandlerAsync]]
  Source Edit

Funcs

func initPath(route: string; httpMethod = HttpGet): Path {...}{.inline, raises: [],
    tags: [].}
  Source Edit
func initRePath(route: Regex; httpMethod = HttpGet): RePath {...}{.inline,
    raises: [], tags: [].}
  Source Edit
func pattern(route: string; handler: HandlerAsync; httpMethod = HttpGet;
             name = ""; middlewares: openArray[HandlerAsync] = @[]): UrlPattern {...}{.
    inline, raises: [], tags: [].}
  Source Edit
func pattern(route: string; handler: HandlerAsync;
             httpMethod: openArray[HttpMethod]; name = "";
             middlewares: openArray[HandlerAsync] = @[]): UrlPattern {...}{.inline,
    raises: [], tags: [].}
  Source Edit
func hash(x: Path): Hash {...}{.inline, raises: [], tags: [].}
  Source Edit
func newReRouter(): ReRouter {...}{.inline, raises: [], tags: [].}
  Source Edit
func add(reRouter: var ReRouter; pairs: (RePath, PathHandler)) {...}{.inline,
    raises: [], tags: [].}
  Source Edit
func `$`(piece: BasePatternNode): string {...}{.raises: [], tags: [].}
  Source Edit
func `$`(node: PatternNode): string {...}{.raises: [], tags: [].}
  Source Edit
func printRoutingTree(router: Router) {...}{.raises: [], tags: [].}
Prints the route.   Source Edit
func newRouter(): Router {...}{.inline, raises: [], tags: [].}
Creates a new Router instance.   Source Edit
func newPathHandler(handler: HandlerAsync; middlewares: seq[HandlerAsync]): PathHandler {...}{.
    inline, raises: [], tags: [].}
  Source Edit
func addRoute(router: Router; route: string; httpMethod: HttpMethod;
              handler: HandlerAsync; middlewares: seq[HandlerAsync]) {...}{.
    raises: [RouteError, KeyError, DuplicatedRouteError], tags: [].}
Add a new mapping to the given Router instance.   Source Edit
func compress(router: Router) {...}{.raises: [], tags: [].}
Compresses the entire contents of the given Router. Successive calls will recompress, but may not be efficient, so use this only when mapping is complete for the best effect   Source Edit
func findHandler(ctx: Context; reqMethod: HttpMethod; path: string): Option[
    PathHandler] {...}{.inline, raises: [KeyError, RouteError], tags: [].}
Simple wrapper around the regular route function.   Source Edit
func stripRoute(route: string): string {...}{.inline, raises: [], tags: [].}
  Source Edit
func findHandler(ctx: Context): PathHandler {...}{.inline,
    raises: [KeyError, RouteError], tags: [].}
fixed route -> params route -> regex route Follow the order of addition.   Source Edit

Iterators

iterator items(reRouter: ReRouter): (RePath, PathHandler) {...}{.raises: [], tags: [].}
  Source Edit