Liking cljdoc? Tell your friends :D

hara.net.http.route


-handler-fncljmultimethod

extensible method for selecting constructor for handler

extensible method for selecting constructor for handler
raw docstring

handlerclj

(handler x)

constructs handler from

((handler [[:get "/hello" (constantly "hello")] [:post "/hello" (constantly "hello post")]]) {:method :post :route "/hello"}) => "hello"

constructs handler from

((handler [[:get  "/hello" (constantly "hello")]
           [:post "/hello" (constantly "hello post")]])
 {:method :post
  :route "/hello"})
=> "hello"
raw docstring

single-handlerclj

(single-handler x)

constructs a single method handler

((single-handler [:get "/" (constantly {:status true})]) {:route "/"}) => {:status true}

(-> ((single-handler [:endpoint "/" {:functions {:add (fn [a b] (+ a b))}}]) {:route "/" :body (str {:id :add :args [1 2]})}) :body read-string) => (contains {:status :return, :data 3, :id :add})

constructs a single method handler

((single-handler [:get "/" (constantly {:status true})])
 {:route "/"})
=> {:status true}

(-> ((single-handler [:endpoint "/" {:functions {:add (fn [a b] (+ a b))}}])
     {:route "/"
      :body (str {:id :add :args [1 2]})})
    :body
    read-string)
=> (contains {:status :return, :data 3, :id :add})
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close