Liking cljdoc? Tell your friends :D

hara.net.http


deleteclj

(delete url)
(delete url opts)

getclj

(get url)
(get url opts)

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

(head url)
(head url opts)

htmlclj

(html rep)

converts either node or tree representation to a html string

(html [:body [:div "hello"] "world"]) => "<body>\n <div>hello</div>world\n</body>"

converts either node or tree representation to a html string

(html [:body [:div "hello"] "world"])
=> "<body>\n    <div>hello</div>world\n</body>"
raw docstring

mock-endpointclj

(mock-endpoint handler route)
(mock-endpoint handler route {:keys [format] :or {format :edn}})

creates a mock-endpoint for testing

((mock-endpoint (fn [req] {:status 200 :body (str {:status :return :data req})}) "/endpoint") {:id :add :args [1 2 3]}) => {:method :post, :route "/endpoint", :body "{:id :add, :args [1 2 3]}"}

creates a mock-endpoint for testing

((mock-endpoint (fn [req] {:status 200
                           :body (str {:status :return
                                       :data req})}) "/endpoint")
 {:id   :add
  :args [1 2 3]})
=> {:method :post, :route "/endpoint", :body "{:id :add, :args [1 2 3]}"}
raw docstring

patchclj

(patch url)
(patch url opts)

postclj

(post url)
(post url opts)

putclj

(put url)
(put url opts)

remoteclj

(remote url {:keys [id args format] :as opts :or {format :edn}})

creates a remote access to an endpoint

creates a remote access to an endpoint
raw docstring

requestclj

(request req)
(request req
         {:keys [client as raw type callback error method]
          :as opts
          :or {type :sync as :string method :get client +default-client+}})

performs a http request

(request "http://www.yahoo.com") => (contains {:status number? :body string? :version "HTTP_1_1" :headers map?})

performs a http request

(request "http://www.yahoo.com")
=> (contains {:status number?
              :body string?
              :version "HTTP_1_1"
              :headers map?})
raw docstring

run-serverclj

(run-server handler
            {:keys [host port dispatch?]
             :or {host "localhost" port 80 dispatch? true}
             :as options})

Start an Undertow webserver to serve the given handler according to the supplied options:

:configurator - a function called with the Undertow Builder instance :port - the port to listen on (defaults to 80) :host - the hostname to listen on :io-threads - number of threads to use for I/O (default: number of cores) :worker-threads - number of threads to use for processing (default: io-threads * 8) :dispatch? - dispatch handlers off the I/O threads (default: true)

Returns an Undertow server instance. To stop call (.stop server).

Start an Undertow webserver to serve the given handler according to the
supplied options:

:configurator   - a function called with the Undertow Builder instance
:port           - the port to listen on (defaults to 80)
:host           - the hostname to listen on
:io-threads     - number of threads to use for I/O (default: number of cores)
:worker-threads - number of threads to use for processing (default: io-threads * 8)
:dispatch?      - dispatch handlers off the I/O threads (default: true)

Returns an Undertow server instance. To stop call (.stop server).
raw docstring

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

× close