Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deraen/ring-cljsjs
Ring middleware to serve assets from Cljsjs packages
https://github.com/deraen/ring-cljsjs
Last synced: 2 days ago
JSON representation
Ring middleware to serve assets from Cljsjs packages
- Host: GitHub
- URL: https://github.com/deraen/ring-cljsjs
- Owner: Deraen
- Created: 2016-03-06T16:48:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-14T11:21:25.000Z (about 5 years ago)
- Last Synced: 2024-09-26T05:14:32.365Z (7 days ago)
- Language: Clojure
- Size: 8.79 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Ring-Cljsjs
[![Clojars Project](https://img.shields.io/clojars/v/ring-cljsjs.svg)](https://clojars.org/ring-cljsjs)
Ring middleware to serve static assets from [cljsjs][].
[cljsjs]: http://www.webjars.org/
## Installation
Include the following dependency in your project dependencies:
```
[ring-cljsjs "0.1.0"]
```## Usage
Require the middleware and add it to your handler.
```clj
(require '[ring.middleware.cljsjs :refer [wrap-cljsjs]])(def app (wrap-cljsjs handler))
```Cljsjs assets will then be served from the following path:
```
/cljsjs//
```For example, if you include the [cljsjs/react-mdl "1.4.3-0"] dependency, then the minified material CSS will be available at:
```
/cljsjs/react-mdl/material.min.css
```By default assets are placed on the `/cljsjs` path. You can change
the path by specifying prefix in a options map.```clj
(def app (wrap-cljsjs handler {:prefix "/cljsjs"}))
```### Content-type headers
Similar to Ring [wrap-resource](https://ring-clojure.github.io/ring/ring.middleware.resource.html)
and other middleware, Ring-cljsjs doesn't automatically add content-type headers.
User is expected to use [wrap-content-type](https://ring-clojure.github.io/ring/ring.middleware.content-type.html)
middleware or something comparable.```
(def app
(-> handler
(wrap-resource "public/")
(wrap-cljsjs {:prefix "/cljsjs"})
(wrap-content-type)))
```## License
Copyright © 2016-2019 Juho Teperi
Based on [ring-webjars](https://github.com/weavejester/ring-webjars)
Copyright © 2015 James ReevesReleased under the MIT license.