Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
138 lines (133 sloc) 5.63 KB
---
layout: bounce
title: Home
---
<div id="landing">
<div class="container">
<div class="row">
<div class="span6">
<h1>HTTP client/server for Clojure</h1>
<p>HTTP Kit is a <strong>minimalist</strong>, <strong>efficient</strong>,
<strong>Ring-compatible</strong> HTTP client/server for Clojure. It
uses a <strong>event-driven</strong> architecture to support
<strong>highly concurrent a/synchronous</strong> web applications.
Feature <a href="http://http-kit.org/server.html#channel">a unified API</a> for WebSocket and HTTP long polling/streaming</p>
{% highlight clojure %}
[http-kit "2.2.0"] ; Add to your project.clj.
{% endhighlight %}
<br />
<h3>Recent Blog Posts</h3>
<ul>
{% for post in site.posts %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</div>
<div class="span6">
<h3>HTTP Server <a class="more" href="server.html">documentation</a></h3>
{% highlight clojure %}
(defn async-handler [ring-request]
;; unified API for WebSocket and HTTP long polling/streaming
(with-channel ring-request channel ; get the channel
(if (websocket? channel) ; if you want to distinguish them
(on-receive channel (fn [data] ; two way communication
(send! channel data)))
(send! channel {:status 200
:headers {"Content-Type" "text/plain"}
:body "Long polling?"}))))
(run-server async-handler {:port 8080}) ; Ring server{% endhighlight %}
<h3>HTTP Client <a class="more" href="client.html">documentation</a></h3>
{% highlight clojure %}
;; start concurrent requests, get promise, half the waiting time
(let [response1 (http-kit/get "http://http-kit.org/")
response2 (http-kit/get "http://clojure.org/")]
;; Handle responses one-by-one, blocking as necessary
;; Other keys :headers :body :error :opts
(println "response1's status: " (:status @response1))
(println "response2's status: " (:status @response2))){% endhighlight %}
</div>
</div>
</div>
</div>
<div id="content" class="">
<div class="container txt-middle">
<div class="row">
<div class="span4 bouncy">
<h2>Ring Compliant</h2>
<p>
HTTP Kit is an <a href="migration.html">(almost)</a> drop-in
replacement for the standard Ring Jetty adapter. So you can use it
with all your current libraries
(e.g. <a href="server.html#routing">Compojure</a>)
and middleware.
</p>
</div>
<div class="span4 bouncy">
<h2>High Performance</h2>
<p>
Using an event-driven architecture like Nginx, HTTP-kit
is <a href="https://github.com/ptaoussanis/clojure-web-server-benchmarks">
very, very fast</a>. It comfortably handles tens of thousands of
requests/sec on even midrange hardware.
<a href="http://www.techempower.com/benchmarks/#section=data-r3">Here</a> is another test about how it stacks up with others.
</p>
</div>
<div class="span4 bouncy">
<h2>High Concurrency</h2>
<p>
It's not only fast,
but <a href="600k-concurrent-connection-http-kit.html">efficient</a>!
Each connection costs nothing but a few kB of memory. RAM usage grows O(n) with connections.
</p>
</div>
</div>
<div class="row">
<div class="span4 bouncy">
<h2>Clean, Simple, Small</h2>
<p>
Written from the ground-up to be lean, the entire client/server is
available as a single ~90kB JAR with zero dependencies and
<a href="http-kit-clean-small.html">~3k lines of (mostly Java) code</a>.
</p>
</div>
<div class="span4 bouncy">
<h2>Sync or Async</h2>
<p>
Synchronous is simple. Asynchronous is fast &amp; flexible. With
HTTP Kit you get the best of both with a <a href="client.html">simple API</a> that lets you
mix &amp; match to best fit your use case.
</p>
</div>
<div class="span4 bouncy">
<h2>WebSockets and Comet</h2>
<p>
With great out-the-box support for both
<a href="server.html#websocket">WebSockets</a> and efficient
handling of
<a href="server.html#async">long-held HTTP requests</a>,
realtime web applications are a breeze to write.
</p>
</div>
<div class="span4 offset4 bouncy">
<h2>Open Source</h2>
<p>
HTTP Kit is
on <a href="https://github.com/http-kit/http-kit">GitHub</a> and is
distributed under
the <a href="http://www.apache.org/licenses/LICENSE-2.0.html">
Apache License Version 2.0</a>. Want to make it better? Contributing is just
a pull request away!
</p>
<ul class="bs-docs-social-buttons">
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=http-kit&repo=http-kit&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="102px" height="20px"></iframe>
</li>
<li>
<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=http-kit&repo=http-kit&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe>
</li>
</ul>
</div>
<div class="span4 bounch"></div>
</div>
</div>
</div>