A Clojurescript library to simplify the use with Cloudflare workers, focusing on simplicity.
Clojureflare currently provides three functions, documented here.
worker
, which routes as arguments and attaches the dispatcher to the worker eventsimulate-worker
, serving the same purpose. It acceps a request as a first argument and instead of responding to a worker event returns the response, which simplifies repl development. It avoids any dependencies that would limit the runtime to the browser.route
, creating a new route which expects three argument: method
(e.g. GET, POST), path
(such as /api/v1/ping) and handler (described below).The handler can currently be one of three types:
The request is of the form of
{:path "/test" :body "{\"key\":1}" :headers {}}
while the response map should similar to
{:body "{\"key\":1}" :headers {"Content-Type" "application/json"} :status 200}
Additionally the handler function can return a promise which eventually resolves to the described map.
Head over to the example-worker to create your first Clojurescript worker.