(add-regex-symbols s)
Wrap a regex pattern with forward slashes to make it easier to recognize as a regex
Wrap a regex pattern with forward slashes to make it easier to recognize as a regex
(add-route-name route-info)
Inputs: [route-info :- RouteInfo] Returns: RouteInfoWithId
Given a RouteInfo, compute a route-id and return a RouteInfoWithId.
Inputs: [route-info :- RouteInfo] Returns: RouteInfoWithId Given a RouteInfo, compute a route-id and return a RouteInfoWithId.
(breadth-route-metadata* route-meta route-info loc)
Inputs: [route-meta :- RouteMetadata route-info :- RouteInfo loc :- Zipper] Returns: RouteMetadata
Helper function used to traverse branches of the Bidi route tree, breadth-first.
Inputs: [route-meta :- RouteMetadata route-info :- RouteInfo loc :- Zipper] Returns: RouteMetadata Helper function used to traverse branches of the Bidi route tree, breadth-first.
(context url-prefix & routes)
Inputs: [url-prefix :- bidi-schema/Pattern & routes :- [bidi-schema/RoutePair]] Returns: bidi-schema/RoutePair
Combines multiple bidi routes together into a single data structure, but nests
them all under the given url-prefix. This is similar to compojure's context
macro, but does not accept a binding form. You can still destructure variables
by passing a bidi pattern for url-prefix
, and the variables will be available
to all nested routes.
Inputs: [url-prefix :- bidi-schema/Pattern & routes :- [bidi-schema/RoutePair]] Returns: bidi-schema/RoutePair Combines multiple bidi routes together into a single data structure, but nests them all under the given url-prefix. This is similar to compojure's `context` macro, but does not accept a binding form. You can still destructure variables by passing a bidi pattern for `url-prefix`, and the variables will be available to all nested routes.
(depth-route-metadata* route-meta route-info loc)
Inputs: [route-meta :- RouteMetadata route-info :- RouteInfo loc :- Zipper] Returns: RouteMetadata
Helper function used to traverse branches of the Bidi route tree, depth-first.
Inputs: [route-meta :- RouteMetadata route-info :- RouteInfo loc :- Zipper] Returns: RouteMetadata Helper function used to traverse branches of the Bidi route tree, depth-first.
(handler-fn* bindings body)
Helper macro, used by the compojure-like macros (GET/POST/etc.) to generate a function that provides compojure's destructuring and rendering support.
Helper macro, used by the compojure-like macros (GET/POST/etc.) to generate a function that provides compojure's destructuring and rendering support.
(make-handler route)
Create a Ring handler from the route definition data structure. Matches a handler from the uri in the request, and invokes it with the request as a parameter. (This code is largely copied from the bidi upstream, but we add support for inserting the match-context via middleware.)
Create a Ring handler from the route definition data structure. Matches a handler from the uri in the request, and invokes it with the request as a parameter. (This code is largely copied from the bidi upstream, but we add support for inserting the match-context via middleware.)
(path-element->route-id-element path-element)
Inputs: [path-element :- schema/Str] Returns: schema/Str
Given a String path element from comidi route metadata, convert it into a string suitable for use in building a route id string.
Inputs: [path-element :- schema/Str] Returns: schema/Str Given a String path element from comidi route metadata, convert it into a string suitable for use in building a route id string.
(regex-path-element->route-id-element path-element)
Inputs: [path-element :- RegexPatternSegment] Returns: schema/Str
Given a Regex path element from comidi route metadata, convert it into a string suitable for use in building a route id string.
Inputs: [path-element :- RegexPatternSegment] Returns: schema/Str Given a Regex path element from comidi route metadata, convert it into a string suitable for use in building a route id string.
(resources path & [options])
A route for serving resources on the classpath. Accepts the following keys: :root - the root prefix path of the resources, defaults to 'public' :mime-types - an optional map of file extensions to mime types
A route for serving resources on the classpath. Accepts the following keys: :root - the root prefix path of the resources, defaults to 'public' :mime-types - an optional map of file extensions to mime types
(route-metadata routes)
Inputs: [routes :- bidi-schema/RoutePair] Returns: RouteMetadata
Build up a map of metadata describing the routes. This metadata map can be
used for introspecting the routes after building the handler, and can also
be used with the wrap-with-route-metadata
middleware.
Inputs: [routes :- bidi-schema/RoutePair] Returns: RouteMetadata Build up a map of metadata describing the routes. This metadata map can be used for introspecting the routes after building the handler, and can also be used with the `wrap-with-route-metadata` middleware.
(route-metadata* routes)
Inputs: [routes :- bidi-schema/RoutePair] Returns: RouteMetadata
Traverses a Bidi route tree and returns route metadata, which includes a list of RouteInfo objects (one per route), plus a mechanism to look up the RouteInfo for a given handler.
Inputs: [routes :- bidi-schema/RoutePair] Returns: RouteMetadata Traverses a Bidi route tree and returns route metadata, which includes a list of RouteInfo objects (one per route), plus a mechanism to look up the RouteInfo for a given handler.
(route-path->route-id route-path)
Inputs: [route-path :- [bidi-schema/PatternSegment]] Returns: schema/Str
Given a route path (from comidi route-metadata), build a route-id string for the route. This route-id can be used as a unique identifier for a route.
Inputs: [route-path :- [bidi-schema/PatternSegment]] Returns: schema/Str Given a route path (from comidi route-metadata), build a route-id string for the route. This route-id can be used as a unique identifier for a route.
(route-path-element->route-id-element path-element)
Inputs: [path-element] Returns: schema/Str
Given a route path element from comidi route metadata, convert it into a string suitable for use in building a route id string. This function is mostly responsible for determining the type of the path element and dispatching to the appropriate function.
Inputs: [path-element] Returns: schema/Str Given a route path element from comidi route metadata, convert it into a string suitable for use in building a route id string. This function is mostly responsible for determining the type of the path element and dispatching to the appropriate function.
(route-tree-zip root)
Returns a zipper for a bidi route tree i.e. for an arbitrarily nested structure of
bidi.schema/RoutePair
s
Returns a zipper for a bidi route tree i.e. for an arbitrarily nested structure of `bidi.schema/RoutePair`s
(route-with-method* method pattern bindings body)
Helper function, used by the compojure-like macros (GET/POST/etc.) to generate a bidi route that includes a wrapped handler function.
Helper function, used by the compojure-like macros (GET/POST/etc.) to generate a bidi route that includes a wrapped handler function.
(routes & routes)
Inputs: [& routes :- [bidi-schema/RoutePair]] Returns: bidi-schema/RoutePair
Combines multiple bidi routes into a single data structure; this is largely just a convenience function for grouping several routes together as a single object that can be passed around.
Inputs: [& routes :- [bidi-schema/RoutePair]] Returns: bidi-schema/RoutePair Combines multiple bidi routes into a single data structure; this is largely just a convenience function for grouping several routes together as a single object that can be passed around.
(routes->handler routes)
Inputs: [routes :- bidi-schema/RoutePair] Returns: (schema/pred fn?)
Given a bidi route tree, converts into a ring request handler function
Inputs: [routes :- bidi-schema/RoutePair] Returns: (schema/pred fn?) Given a bidi route tree, converts into a ring request handler function
(slashes->dashes s)
Convert all forward slashes to hyphens
Convert all forward slashes to hyphens
(special-chars->underscores s)
Convert all non-alpha chars except ! * and - to underscores
Convert all non-alpha chars except ! * and - to underscores
(update-route-info* route-info pattern)
Inputs: [route-info :- RouteInfo pattern :- bidi-schema/Pattern] Returns: RouteInfo
Helper function, used to maintain a RouteInfo data structure that represents the current path elements of a route as we traverse the Bidi route tree via zipper.
Inputs: [route-info :- RouteInfo pattern :- bidi-schema/Pattern] Returns: RouteInfo Helper function, used to maintain a RouteInfo data structure that represents the current path elements of a route as we traverse the Bidi route tree via zipper.
(wrap-routes routes middleware)
Inputs: [routes :- bidi-schema/RoutePair middleware :- (schema/pred fn?)] Returns: bidi-schema/RoutePair
Wraps middleware around the handlers at every leaf in the route in a manner analagous to compojure's wrap-routes function
Inputs: [routes :- bidi-schema/RoutePair middleware :- (schema/pred fn?)] Returns: bidi-schema/RoutePair Wraps middleware around the handlers at every leaf in the route in a manner analagous to compojure's wrap-routes function
(wrap-routes* loc middleware)
Help function, used by compojure-like wrap-routes function to wrap leaf handlers in the bidi route with the middleware
Help function, used by compojure-like wrap-routes function to wrap leaf handlers in the bidi route with the middleware
(wrap-with-route-metadata app routes)
Inputs: [app :- (schema/pred fn?) routes :- bidi-schema/RoutePair] Returns: (schema/pred fn?)
Ring middleware; adds the comidi route-metadata to the request map, as well as a :route-info key that can be used to determine which route a given request matches.
Inputs: [app :- (schema/pred fn?) routes :- bidi-schema/RoutePair] Returns: (schema/pred fn?) Ring middleware; adds the comidi route-metadata to the request map, as well as a :route-info key that can be used to determine which route a given request matches.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close