fomkin / vodka   0.2.1


(joke-project) Small HTTP service library, no dependencies.

Scala versions: 2.11 2.10


Life in Russia is very hard. Usually we are drunk when Putin coerce us to write Scala code. So I decided to create a library with which even drunk bear can make microservice. Vodka is a small HTTP/1.1 server (less than 1000 lines of code) created without any dependencies on top of NIO2.


Let's be fair, Play and akka-http are too large and too complicated for making small services. When I searching for alternatives I found two libraries looks good to me: Colossus and Http4s. Both have simple zero boilerplate bootstrap and great routing API. But Colossus depends on Akka (not every service needs Akka) and Http4s depends on Scalaz (What if I want Cats?). Obviously, we need yet another service library!


Give a drink vodka to your SBT

libraryDependencies += "com.github.fomkin" %% "vodka-http" % "0.2.1"


import scala.concurrent.Future
import vodka._

object Main extends App {
  Vodka() {
    case request <| GET -> Root / "hello" / name =>
      var res = HttpResponse.Ok(s"Hello, comrade $name. Let's drink vodka.")

// $ sbt run
// $ curl http://localhost:9090/hello/Ivan
// Hello, comrade Ivan. Let's drink vodka.


Vodka takes configuration via Vodka constructor.

Argument Description
host Host to bind. by default.
port Port to bind. 8080 by default.
logError Function for error logging. println by default.
notFoundHandler Response generator when no route was matched.
errorHandler Response generator when exception was thrown.
maxContentLength Max size of input body

JSON with Pushka


libraryDependencies += "com.github.fomkin" %% "vodka-pushka" % "0.2.1"
import pushka._
import vodka.pushkaSupport._

case class Person(name: String, age: Int)
Vodka() {
  case fromJson(body) <| POST -> Root / "hello" =>
    val person = read[Person](body)

That's all. Enjoy and na zdorovie!