Clojure library for interacting with Caddy via the HTTP Admin API
Tested with Caddy v2.2.0
(require '[cawdy.core :as cawdy])
(cawdy/config)
=> {:apps
{:http
{:servers
{:my-id
{:listen ["localhost:2016"],
:routes
[{:handle
[{:handler "file_server", :root "/tmp/cawdytest2"}]}]}}}}})
(cawdy/add-server "http://localhost:2019"
:my-server-id
:static
{:body "This gets returned"})
$ curl --silent localhost:2019
This gets returned
Options for :static handler can be:
:listen
- Listen address of the server, defaults to ":2015":body
- What to send in the response body:host
- What host header is needed for getting the response, defaults to "localhost"(cawdy/add-server "http://localhost:2019"
:my-server-id
:files
{:directory "/etc"})
$ curl --silent localhost:2019/hosts
# Static table lookup for hostnames.
...
Options for :files handler are:
:listen
- Listen address of the server, defaults to ":2015":directory
- What directory should act as the root directory:host
- What host header is needed for getting the response, defaults to "localhost"Make sure you have caddy running (via caddy run
) before trying to run tests.
Also, don't run the tests with a caddy instance whos config is important as the tests will remove the existing config before each test.
Copyright © 2020 Victor Bjelkholm under MIT license, see LICENSE
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close