Skip to content

Commit e84f3a4

Browse files
committed
Update README with project information
1 parent bef562f commit e84f3a4

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,54 @@
11
# Duct Handler [![Build Status](https://github.com/duct-framework/handler/actions/workflows/test.yml/badge.svg)](https://github.com/duct-framework/handler/actions/workflows/test.yml)
22

3-
A Clojure library designed to ... well, that part is up to you.
3+
A library that provides common [Ring][] handlers for the [Duct][]
4+
framework.
5+
6+
[ring]: https://github.com/ring-clojure/ring
7+
[duct]: https://github.com/duct-framework/duct
8+
9+
## Installation
10+
11+
Add the following dependency to your deps.edn file:
12+
13+
org.duct-framework/handler {:mvn/version "0.1.0-SNAPSHOT"}
14+
15+
Or to your Leiningen project file:
16+
17+
[org.duct-framework/handler "0.1.0-SNAPSHOT"]
418

519
## Usage
620

7-
FIXME
21+
This library provides three [Integrant][] keys that initiate into Ring
22+
handlers.
23+
24+
`:duct.handler/static` creates a handler that always returns the same
25+
response map. The value of this key is the response map itself.
26+
27+
`:duct.handler/file` and `:duct.handler/resource` are handlers that
28+
return files or resources. They take two options:
29+
30+
- `:paths` - a map of paths strings to an option map
31+
- `:not-found` - a response map to be returned if no path matches
32+
33+
If the `:not-found` option is not supplied, `nil` is returned from the
34+
handler (which can be useful for trying multiple handlers to see which
35+
matches).
36+
37+
The options mapped from each path go directly to the
38+
[ring.util.reponse/file-response][file-resp] and
39+
[ring.util.response/resource-response][res-resp] functions.
40+
41+
For example:
42+
43+
```edn
44+
{:duct.handler/file
45+
{"/" {:root "public"}
46+
"/js" {:root "target/js"}}}
47+
```
48+
49+
[integrant]: https://github.com/weavejester/integrant
50+
[file-resp]: https://ring-clojure.github.io/ring/ring.util.response.html#var-file-response
51+
[res-resp]: https://ring-clojure.github.io/ring/ring.util.response.html#var-resource-response
852

953
## License
1054

0 commit comments

Comments
 (0)