(route method path handler)
Create a new route with the given parameters: method: string, such as GET, POST, DELETE, ... path: string, e.g /my/api/v1/operation handler: either a string, which will be returned on a request with status code 200 and a text/html content-type map, which will be returned as a JSON with status code 200 and a application/json content-type function, which takes zero or one parameter. That function must return a map containing the keywords - :body (required, string) - :headers (map, optional, default {}) - :status (integer, optional, default 200) Alternatively it can return a promise that resolves to the map mentioned above. Promise rejections are currently not handled. If the function takes a parameter it will be the request made, using the same structure as above.
Create a new route with the given parameters: method: string, such as GET, POST, DELETE, ... path: string, e.g /my/api/v1/operation handler: either a string, which will be returned on a request with status code 200 and a text/html content-type map, which will be returned as a JSON with status code 200 and a application/json content-type function, which takes zero or one parameter. That function must return a map containing the keywords - :body (required, string) - :headers (map, optional, default {}) - :status (integer, optional, default 200) Alternatively it can return a promise that resolves to the map mentioned above. Promise rejections are currently not handled. If the function takes a parameter it will be the request made, using the same structure as above.
(simulate-worker req & routes)
A function to simplify REPL development by simulating how a request would be routed and handled. The requests are maps with the keywords :status :headers :body :method, similiar as described in the route function
A function to simplify REPL development by simulating how a request would be routed and handled. The requests are maps with the keywords :status :headers :body :method, similiar as described in the route function
(worker & routes)
Takes all routes and registers the fetch event from the worker environment. Should only be called once per worker.
Takes all routes and registers the fetch event from the worker environment. Should only be called once per worker.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close