Liking cljdoc? Tell your friends :D

lambdaisland.hiccup.middleware


default-layoutclj

(default-layout {:html/keys [head body]})

Basic layout function used when no specific layout is provided.

Basic layout function used when no specific layout is provided.
sourceraw docstring

wrap-renderclj

(wrap-render handler)
(wrap-render handler
             {:keys [layout-fn route-data-fn accept content-type]
              :or {layout-fn default-layout
                   route-data-fn (comp :data :reitit.core/match)
                   accept #{"text/html"}
                   content-type "text/html; charset=utf-8"}})

Content negotiation for html/hiccup.

If the client accepts "text/html", and the response contains a :html/body (hiccup form), then use it to render a HTML response. If the client asks for a different media type, then the request is passed on for other middleware to act upon, e.g. render the :body with Muuntaja.

Additionally :html/layout and :html/head can be provided, either in the response map, or in (Reitit) route data. Layout-fn receives the request map plus two additional keys, :html/body and :html/head, both containing a hiccup element or fragment, which should be inserted in the head and body elements respectively.

:html/head can be used to set the page title, social media tags, etc.

The response status if not set defaults to 200.

Middleware options

  • :layout-fn - fallback layout function
  • :route-data-fn - function from request map to route data
  • :accept - set of mime types that should trigger hiccup rendering
  • :content-type - content-type of the response
Content negotiation for html/hiccup.

If the client accepts "text/html", and the response contains a
`:html/body` (hiccup form), then use it to render a HTML response. If the
client asks for a different media type, then the request is passed on for
other middleware to act upon, e.g. render the `:body` with Muuntaja.

Additionally `:html/layout` and `:html/head` can be provided, either in the
response map, or in (Reitit) route data. Layout-fn receives the request map
plus two additional keys, `:html/body` and `:html/head`, both containing a
hiccup element or fragment, which should be inserted in the head and body
elements respectively.

`:html/head` can be used to set the page title, social media tags, etc.

The response status if not set defaults to 200.

Middleware options

- `:layout-fn` - fallback layout function
- `:route-data-fn` - function from request map to route data
- `:accept` - set of mime types that should trigger hiccup rendering
- `:content-type` - content-type of the response
sourceraw docstring

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

× close