HTTP APIs with Finagle, TwitterServer and Finch
finagle-core
- 40k LOC; finagle-httpx
- 10k LOChere I updated the XKCD comic for you pic.twitter.com/pwPBIghTV3
— monorepi (@monorepi) December 8, 2014
trait Service[-Req, +Req] extends (Req => Future[Rep])
Httpx.client.newService
) ServicesHttpx.server.serve
) Services<Protocol>.client
and <Protocol>.server
ClientBuilder
and ServerBuilder
Stack
of modules (ServiceFactories)Stack
HList
instead of custom composite typesI'm glad to see that other OSS #Scala projects benefit from Finch. Today's examples: https://t.co/9Ipg5d8QN0 and https://t.co/vej6kw2Fbg
— Vladimir Kostyukov (@vkostyukov) June 16, 2015
trait RequestReader[A] extends (Request => Future[A]) {
def ::[B](that: RequestReader[B]): RequestReader[A :: B :: HNil]
}
...
def param(name: String): RequestReader[String] = ???
def paramOption(name: String): RequesReader[Option[String]] = ???
val body: RequestReader[String] = ???
val bodyOption: RequestReader[Option[String]] = ???
...
trait Router[A] extends (Input => Option[(Input, () => Future[A])]) {
def /[B](that: Router[B]): Router[A :: B :: HNil]
def :+:[B](that: Router[B]): Router[A :+: B :+: CNil]
def ?[B](that: RequestReader[B]): Router[A :: B :: HNil]
}
...
val int: Router[Int] = ???
val string: Router[String] = ???
...
GET /todos
; POST /todos
; PATCH /todos/:id
DELETE /todos/:id
; DELETE /todos
case class Todo(
id: String, title: String, completed: Boolean, order: Int
)
Want to build libraries that hundreds of millions of people rely on every day? Here's your chance: https://t.co/BOV3Pdm6f8 /cc @JoinTheFlock
— Finagle (@finagle) July 2, 2015