• (wrap-static app public-dir statics)
Like ring.file, but takes an additional statics, a coll of Strings that will
be used to test incoming requests uris. If a uri begins with any of the
strings in the statics coll, the middleware will check to see if a file can be
served from the public-dir before proxying back to the given app; if the uri
does not correspond to one of these strings, the middleware proxies the
request directly back to the app without touching the filesystem.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source ring/middleware/static.clj:5 top

(defn wrap-static
  "Like ring.file, but takes an additional statics, a coll of Strings that will
  be used to test incoming requests uris. If a uri begins with any of the
  strings in the statics coll, the middleware will check to see if a file can be
  served from the public-dir before proxying back to the given app; if the uri
  does not correspond to one of these strings, the middleware proxies the
  request directly back to the app without touching the filesystem."
  [app public-dir statics]
  (let [app-with-file (wrap-file app public-dir)]
    (fn [req]
      (let [#^String uri (:uri req)]
        (if (some #(.startsWith uri %) statics)
          (app-with-file req)
          (app req))))))
Vars in ring.middleware.static/wrap-static: defn fn let some
Used in 0 other vars

Comments top

No comments for wrap-static. Log in to add a comment.