Liking cljdoc? Tell your friends :D

reitit.ring


-compile-coercionclj/s

(-compile-coercion {:keys [coercion] :as data})
source

-create-file-or-resource-handlerclj

(-create-file-or-resource-handler
  response-fn
  {:keys [parameter root path loader allow-symlinks? index-files paths
          not-found-handler]
   :or {parameter (keyword "")
        root "public"
        index-files ["index.html"]
        paths (constantly nil)
        not-found-handler (if path
                              (constantly nil)
                              (constantly
                                {:status 404 :body "" :headers {}}))}})
source

-update-pathsclj/s

(-update-paths f)
source

coerce-handlerclj/s

(coerce-handler [path data] {:keys [expand] :as opts})
source

compile-resultclj/s

(compile-result [path data]
                {:keys [:reitit.ring/default-options-endpoint expand] :as opts})
source

create-default-handlerclj/s

(create-default-handler)
(create-default-handler
  {:keys [not-found method-not-allowed not-acceptable]
   :or {not-found (constantly {:status 404 :body "" :headers {}})
        method-not-allowed (constantly {:status 405 :body "" :headers {}})
        not-acceptable (constantly {:status 406 :body "" :headers {}})}})

A default ring handler that can handle the following cases, configured via options:

keydescription
:not-found404, no routes matches
:method-not-allowed405, no method matches
:not-acceptable406, handler returned nil
A default ring handler that can handle the following cases,
configured via options:

| key                    | description |
| -----------------------|-------------|
| `:not-found`           | 404, no routes matches
| `:method-not-allowed`  | 405, no method matches
| `:not-acceptable`      | 406, handler returned `nil`
sourceraw docstring

create-enrich-default-requestclj/s

(create-enrich-default-request inject-router?)
source

create-enrich-requestclj/s

(create-enrich-request inject-match? inject-router?)
source

create-file-handlerclj

(create-file-handler)
(create-file-handler opts)

A ring handler for serving file resources, configured via options:

keydescription
:parameteroptional name of the wildcard parameter, defaults to unnamed keyword :
:rootoptional resource root, defaults to "public"
:pathpath to mount the handler to. Required when mounted outside of a router, does not work inside a router.
:loaderoptional class loader to resolve the resources
:index-filesoptional vector of index-files to look in a resource directory, defaults to ["index.html"]
:not-found-handleroptional handler function to use if the requested resource is missing (404 Not Found)
A ring handler for serving file resources, configured via options:

| key                | description |
| -------------------|-------------|
| :parameter         | optional name of the wildcard parameter, defaults to unnamed keyword `:`
| :root              | optional resource root, defaults to `"public"`
| :path              | path to mount the handler to. Required when mounted outside of a router, does not work inside a router.
| :loader            | optional class loader to resolve the resources
| :index-files       | optional vector of index-files to look in a resource directory, defaults to `["index.html"]`
| :not-found-handler | optional handler function to use if the requested resource is missing (404 Not Found)
sourceraw docstring

create-resource-handlerclj

(create-resource-handler)
(create-resource-handler opts)

A ring handler for serving classpath resources, configured via options:

keydescription
:parameteroptional name of the wildcard parameter, defaults to unnamed keyword :
:rootoptional resource root, defaults to "public"
:pathpath to mount the handler to. Required when mounted outside of a router, does not work inside a router.
:loaderoptional class loader to resolve the resources
:index-filesoptional vector of index-files to look in a resource directory, defaults to ["index.html"]
:not-found-handleroptional handler function to use if the requested resource is missing (404 Not Found)
A ring handler for serving classpath resources, configured via options:

| key                | description |
| -------------------|-------------|
| :parameter         | optional name of the wildcard parameter, defaults to unnamed keyword `:`
| :root              | optional resource root, defaults to `"public"`
| :path              | path to mount the handler to. Required when mounted outside of a router, does not work inside a router.
| :loader            | optional class loader to resolve the resources
| :index-files       | optional vector of index-files to look in a resource directory, defaults to `["index.html"]`
| :not-found-handler | optional handler function to use if the requested resource is missing (404 Not Found)
sourceraw docstring

default-options-endpointclj/s

source

default-options-handlerclj/s

source

get-matchclj/s

(get-match request)
source

get-routerclj/s

(get-router handler)
source

group-keysclj/s

(group-keys data)
source

http-methodsclj/s

source

redirect-trailing-slash-handlerclj/s

(redirect-trailing-slash-handler)
(redirect-trailing-slash-handler {:keys [method]})

A ring handler that redirects a missing path if there is an existing path that only differs in the ending slash.

keydescription
:method:add - redirects slash-less to slashed
:strip - redirects slashed to slash-less
:both - works both ways (default)
A ring handler that redirects a missing path if there is an
existing path that only differs in the ending slash.

| key     | description |
|---------|-------------|
| :method | :add - redirects slash-less to slashed |
|         | :strip - redirects slashed to slash-less |
|         | :both - works both ways (default) |
sourceraw docstring

reloading-ring-handlerclj/s

(reloading-ring-handler f)

Returns a ring-handler that recreates the actual ring-handler for each request. Takes a 0-arity function that should return a valid ring-handler. Effectively creates an auto-reloading ring-handler, which is good for REPL-driven development.

Example:

  ;; for dev-mode, recreate the ring-handler for each request, for prod, just once
  (let [dev-mode ...
        f (fn [] (reitit.ring/ring-handler ...)]
    (if dev-mode (reitit.ring/reloading-ring-handler f) (f)))
Returns a ring-handler that recreates the actual ring-handler for each request.
Takes a 0-arity function that should return a valid ring-handler. Effectively creates
an auto-reloading ring-handler, which is good for REPL-driven development.

Example:

      ;; for dev-mode, recreate the ring-handler for each request, for prod, just once
      (let [dev-mode ...
            f (fn [] (reitit.ring/ring-handler ...)]
        (if dev-mode (reitit.ring/reloading-ring-handler f) (f)))
sourceraw docstring

ring-handlerclj/s

(ring-handler router)
(ring-handler router default-handler)
(ring-handler router
              default-handler
              {:keys [middleware inject-match? inject-router?]
               :or {inject-match? true inject-router? true}})

Creates a ring-handler out of a router, optional default ring-handler and options map, with the following keys:

keydescription
:middlewareOptional sequence of middleware that wrap the ring-handler
:inject-match?Boolean to inject match into request under :reitit.core/match key (default true)
:inject-router?Boolean to inject router into request under :reitit.core/router key (default true)
Creates a ring-handler out of a router, optional default ring-handler
and options map, with the following keys:

| key               | description |
| ------------------|-------------|
| `:middleware`     | Optional sequence of middleware that wrap the ring-handler
| `:inject-match?`  | Boolean to inject `match` into request under `:reitit.core/match` key (default true)
| `:inject-router?` | Boolean to inject `router` into request under `:reitit.core/router` key (default true)
sourceraw docstring

routerclj/s

(router data)
(router data opts)

Creates a [[reitit.core/Router]] from raw route data and optionally an options map with support for http-methods and Middleware. See documentation on [[reitit.core/router]] for available options. In addition, the following options are available:

keydescription
:reitit.middleware/transformFunction or vector of functions of type [Middleware] => [Middleware] to transform the expanded Middleware (default: identity)
:reitit.middleware/registryMap of keyword => IntoMiddleware to replace keyword references into Middleware
:reitit.ring/default-options-endpointDefault endpoint for :options method in endpoints (default: default-options-endpoint)

Example:

(router
  ["/api" {:middleware [wrap-format wrap-oauth2]}
    ["/users" {:get get-user
                 :post update-user
                 :delete {:middleware [wrap-delete]
                         :handler delete-user}}]])
Creates a [[reitit.core/Router]] from raw route data and optionally an options map with
support for http-methods and Middleware. See documentation on [[reitit.core/router]] for
available options. In addition, the following options are available:

| key                                     | description
| ----------------------------------------|-------------
| `:reitit.middleware/transform`          | Function or vector of functions of type `[Middleware] => [Middleware]` to transform the expanded Middleware (default: identity)
| `:reitit.middleware/registry`           | Map of `keyword => IntoMiddleware` to replace keyword references into Middleware
| `:reitit.ring/default-options-endpoint` | Default endpoint for `:options` method in endpoints (default: default-options-endpoint)

Example:

    (router
      ["/api" {:middleware [wrap-format wrap-oauth2]}
        ["/users" {:get get-user
                     :post update-user
                     :delete {:middleware [wrap-delete]
                             :handler delete-user}}]])
sourceraw docstring

routesclj/s

(routes & handlers)

Create a ring handler by combining several handlers into one.

Create a ring handler by combining several handlers into one.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close