|
1 | 1 | {:duct.module/web |
2 | 2 | {:duct/vars |
3 | 3 | {port {:env PORT, :arg port, :type :int, :default 3000 |
4 | | - :doc "The HTTP server port (default: 3000)"}}}} |
| 4 | + :doc "The HTTP server port (default: 3000)"}} |
| 5 | + :doc |
| 6 | + "A module that adds components for web applications to the configuration. |
| 7 | +
|
| 8 | + Takes the following options: |
| 9 | + - `:features` - a set of keywords that specify which features to add |
| 10 | + - `:handler-opts` - a map of options passed to all route handlers |
| 11 | + - `:middleware` - an ordered collection of middleware functions |
| 12 | + - `:middleware-opts` - a map of options passed to all middleware |
| 13 | + - `:route-middleware` - middleware that is only applied if a route matches |
| 14 | + - `:routes` - routing data passed to the [Reitit][1] router |
| 15 | +
|
| 16 | + The *features* of the module determine how the module should be configured. |
| 17 | + - `:api` - add middleware and configration for a RESTful web API |
| 18 | + - `:site` - add middleware and configuration for a user-facing web app |
| 19 | +
|
| 20 | + A Duct `port` variable is added to configure the port the HTTP server will |
| 21 | + run on (default 3000). |
| 22 | +
|
| 23 | + Keyword endpoints in the `:routes` will be converted into refs to handlers, |
| 24 | + and any missing handler will be added to the configuration. |
| 25 | +
|
| 26 | + [1]: https://github.com/metosin/reitit"} |
| 27 | + |
| 28 | + :duct.middleware.web/log-requests |
| 29 | + {:doc |
| 30 | + "Ring middleware to log each request. Takes the following options: |
| 31 | + - `:logger` - a logger satisfying `duct.logger/Logger` |
| 32 | + - `:level` - the level to log requests at (default `:info`)"} |
| 33 | + |
| 34 | + :duct.middleware.web/log-errors |
| 35 | + {:doc |
| 36 | + "Ring middleware to log uncaught exceptions. Takes the following options: |
| 37 | + - `:logger` - a logger satisfying `duct.logger/Logger`"} |
| 38 | + |
| 39 | + :duct.middleware.web/hide-errors |
| 40 | + {:doc |
| 41 | + "Ring mddleware that hides any uncaught exceptions behind a 500 'Internal |
| 42 | + Error' response generated by an error handler. Intended for use in production |
| 43 | + when exception details need to be hidden. |
| 44 | +
|
| 45 | + Takes the following options: |
| 46 | + - `:error-handler` - the error handler used when there are exceptions"} |
| 47 | + |
| 48 | + :duct.middleware.web/defaults |
| 49 | + {:doc |
| 50 | + "A collection of sensible Ring middleware defaults, using the |
| 51 | + [Ring-Defaults][1] library. Takes a Ring-Defaults configuration as its |
| 52 | + options map. |
| 53 | +
|
| 54 | + [1]: https://github.com/ring-clojure/ring-defaults"} |
| 55 | + |
| 56 | + :duct.middleware.web/webjars |
| 57 | + {:doc |
| 58 | + "Ring middleware to serve static resources from [WebJars][1]. Takes |
| 59 | + the following options: |
| 60 | + - `:path` - the path to serve the assets on (default \"/assets\")"} |
| 61 | + |
| 62 | + :duct.middleware.web/stacktrace |
| 63 | + {:doc |
| 64 | + "Ring middleware that generates a stacktrace for uncaught exceptions. |
| 65 | + Intended for development use when seeing the stacktrace could be useful. |
| 66 | +
|
| 67 | + Takes the following options: |
| 68 | + - `:color?` - if true, use ANSI colors at the terminal (default false)"} |
| 69 | + |
| 70 | + :duct.middleware.web/hiccup |
| 71 | + {:doc |
| 72 | + "Ring middleware that looks for response bodies that contain [Hiccup][1] |
| 73 | + vectors, and renders them as a string of HTML5. |
| 74 | +
|
| 75 | + Takes the following options: |
| 76 | + - `:hiccup-renderer` - a function to render Hiccup (defaults to using |
| 77 | + `hiccup2.core/html`) |
| 78 | +
|
| 79 | + [1]: https://github.com/weavejester/hiccup"}} |
0 commit comments