Back
wrap-base-url (clj)
(source)function
(wrap-base-url handler)
(wrap-base-url handler base-url)
Ring middleware that wraps the handler in the [[with-base-url]] function.
The base URL may be specified as an argument. Otherwise, the `:context` key
on the request map is used.
Examples
hiccup
(ns hiccup.middleware_test
(:require [clojure.test :refer :all]
[hiccup.core :refer [html]]
[hiccup.element :refer [link-to]]
[hiccup.middleware :refer :all]))
(deftest test-wrap-base-url
(let [resp ((wrap-base-url test-handler "/foo") {})]
(is (= (:body resp)
"<html><body><a href=\"/foo/bar\">bar</a></body></html>"))))
rm-hull/lindenmayer-systems
(ns lindenmayer.handler
(:require
[compojure.core :refer [defroutes]]
[compojure.handler :as handler]
[compojure.route :as route]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.gzip :refer [wrap-gzip]]
[hiccup.middleware :refer [wrap-base-url]]
[ring.logger.timbre :as logger.timbre]
[metrics.ring.expose :refer [expose-metrics-as-json]]
[metrics.ring.instrument :refer [instrument]]
[lindenmayer.explorer :as explorer]))
(def app
(->
app-routes
(logger.timbre/wrap-with-logger)
(expose-metrics-as-json)
(instrument)
(wrap-base-url)
(wrap-params)
(wrap-gzip)
(handler/api)))
aliostad/deep-learning-lang-detection
(ns lindenmayer.handler
(:require
[compojure.core :refer [defroutes]]
[compojure.handler :as handler]
[compojure.route :as route]
[ring.middleware.params :refer [wrap-params]]
[ring.middleware.gzip :refer [wrap-gzip]]
[hiccup.middleware :refer [wrap-base-url]]
[ring.logger.timbre :as logger.timbre]
[metrics.ring.expose :refer [expose-metrics-as-json]]
[metrics.ring.instrument :refer [instrument]]
[lindenmayer.explorer :as explorer]))
(def app
(->
app-routes
(logger.timbre/wrap-with-logger)
(expose-metrics-as-json)
(instrument)
(wrap-base-url)
(wrap-params)
(wrap-gzip)
(handler/api)))