src/prologue/core/route

Source   Edit  

Types

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

Procs

func `$`(node: PatternNode): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `$`(piece: BasePatternNode): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
func add(reRouter: var ReRouter; pairs: (RePath, PathHandler)) {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func addRoute(router: Router; route: string; httpMethod: HttpMethod;
              handler: HandlerAsync; middlewares: seq[HandlerAsync]) {.
    ...raises: [RouteError, KeyError, DuplicatedRouteError], tags: [], forbids: [].}
Add a new mapping to the given Router instance. Source   Edit  
func compress(router: Router) {....raises: [], tags: [], forbids: [].}
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): PathHandler {.inline, ...raises: [KeyError],
    tags: [RootEffect], forbids: [].}
fixed route -> params route -> regex route Follow the order of addition. Source   Edit  
func findHandler(ctx: Context; reqMethod: HttpMethod; path: string): Option[
    PathHandler] {.inline, ...raises: [KeyError], tags: [], forbids: [].}
Simple wrapper around the regular route function. Source   Edit  
func hash(x: Path): Hash {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
func initPath(route: string; httpMethod = HttpGet): Path {.inline, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
func initRePath(route: Regex; httpMethod = HttpGet): RePath {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func newPathHandler(handler: HandlerAsync; middlewares: seq[HandlerAsync]): PathHandler {.
    inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
func newReRouter(): ReRouter {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
func newRouter(): Router {.inline, ...raises: [], tags: [], forbids: [].}
Creates a new Router instance. Source   Edit  
func pattern(route: string; handler: HandlerAsync; httpMethod = HttpGet;
             name = ""; middlewares: openArray[HandlerAsync] = @[]): UrlPattern {.
    inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
func pattern(route: string; handler: HandlerAsync;
             httpMethod: openArray[HttpMethod]; name = "";
             middlewares: openArray[HandlerAsync] = @[]): UrlPattern {.inline,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
func printRoutingTree(router: Router) {....raises: [], tags: [], forbids: [].}
Prints the route. Source   Edit  
func stripRoute(route: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
Source   Edit  

Iterators

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