Skip to content

Instantly share code, notes, and snippets.

@tomatophobia
Created May 28, 2021 13:43
Show Gist options
  • Save tomatophobia/c9fd4e489eeeaeadf1f01f2aed18382d to your computer and use it in GitHub Desktop.
Save tomatophobia/c9fd4e489eeeaeadf1f01f2aed18382d to your computer and use it in GitHub Desktop.
type Http[F[_]] = Kleisli[F, Request, Response]
type HttpApp = Http[Future]
object HttpApp {
def apply(f: Request => Future[Response]): HttpApp =
Kleisli(f)
}
case class OptionFuture[A](value: Option[Future[A]])
type HttpRoutes = Http[OptionFuture]
object HttpRoutes {
def of(pf: PartialFunction[Request, Future[Response]]): HttpRoutes =
Kleisli(pf.lift.andThen(OptionFuture(_)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment