(defendpoint sym url-template & body)
Shorthand syntax for defining and endpoint and configuring it.
Ex.
(defendpoint all "/users" (method :get)
(on-status
(200 [{:keys [body]}]
(let [c (count (:body resp))]
(js/console.log c "USERS FOUND")))))
Shorthand syntax for defining and endpoint and configuring it. Ex. (defendpoint all "/users" (method :get) (on-status (200 [{:keys [body]}] (let [c (count (:body resp))] (js/console.log c "USERS FOUND")))))
(defservice sym & body)
Shorthand syntax for defining a service and configuring it.
Ex.
(defservice user-service (on-status (200 [_] (js/console.log "SUCCESS"))) (endpoint :all "/users" (method :get)))
Shorthand syntax for defining a service and configuring it. Ex. (defservice user-service (on-status (200 [_] (js/console.log "SUCCESS"))) (endpoint :all "/users" (method :get)))
(endpoint service-spec key url-template & config)
Shorthand syntax to add :on-response configuration to an endpoint or service spec.
Ex. (endpoint {} "/users/:id" (method :get))
Shorthand syntax to add :on-response configuration to an endpoint or service spec. Ex. (endpoint {} "/users/:id" (method :get))
(headers spec headers)
Shortand syntax to add :headers configuration to an endpoint spec.
Ex. (headers {} {"X-Foo" "bar"})
Shortand syntax to add :headers configuration to an endpoint spec. Ex. (headers {} {"X-Foo" "bar"})
(make-endpoint
{:keys [method url-template on-request on-status on-exception headers username
password]
:or {on-request identity on-status {} on-exception identity headers {}}
:as opts})
(make-service {:keys [endpoints] :as service-spec})
Return a function which takes an endpoint key and any number of additional arguments and applies the function given by (make-endpoint (get-in service-spec [:endpoints key])). If the service-spec includes configuration for :headers, :on-status, or :on-request, the endpoint configuration will be merged in to it.
Options:
make-endpoint
for endpoint-config details.Return a function which takes an endpoint key and any number of additional arguments and applies the function given by (make-endpoint (get-in service-spec [:endpoints key])). If the service-spec includes configuration for :headers, :on-status, or :on-request, the endpoint configuration will be merged in to it. Options: * headers - A map of headers to use with each HTTP request. * on-status - A map of status code to response handler. * on-request - A function of at least one arity which accepts the request map as it's first argument. * endpoints - A map of endpoint-key to endpoint-config. See `make-endpoint` for endpoint-config details.
(method spec method)
Shortand syntax to add :method configuration to an endpoint spec.
Ex. (method {} :get)
Shortand syntax to add :method configuration to an endpoint spec. Ex. (method {} :get)
(on-exception spec & fn-tail)
Shorthand syntax to add :on-exception configuation to an endpoint or spec.
Ex. (on-exception {} [err] (println "ERROR: " (.getMessage err))
Shorthand syntax to add :on-exception configuation to an endpoint or spec. Ex. (on-exception {} [err] (println "ERROR: " (.getMessage err))
(on-request spec & fn-tail)
Shorthand syntax to add :on-request configuation to an endpoint or spec.
Ex. (on-request {} [req] (assoc-in req [:headers "X-Foo"] "bar"))
Shorthand syntax to add :on-request configuation to an endpoint or spec. Ex. (on-request {} [req] (assoc-in req [:headers "X-Foo"] "bar"))
(on-status spec & fn-specs)
Shorthand syntax to add :on-status configuation to an endpoint or service spec.
Ex. (on-status {} (200 [_] (pritnln "YAY!")) (404 [_] (println "BOO!")))
Shorthand syntax to add :on-status configuation to an endpoint or service spec. Ex. (on-status {} (200 [_] (pritnln "YAY!")) (404 [_] (println "BOO!")))
(template s)
(template s {:keys [regex]})
Return a string template fn from s.
Return a string template fn from s.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close