-
-
Save tomatophobia/408ddb1fb97e9dfa2d5daef40594bca1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.quickstart | |
| import cats.effect.Sync | |
| import cats.implicits._ | |
| import org.http4s.HttpRoutes | |
| import org.http4s.dsl.Http4sDsl | |
| object QuickstartRoutes { | |
| def jokeRoutes[F[_]: Sync](J: Jokes[F]): HttpRoutes[F] = { | |
| val dsl = new Http4sDsl[F]{} | |
| import dsl._ | |
| HttpRoutes.of[F] { | |
| case GET -> Root / "joke" => | |
| for { | |
| joke <- J.get | |
| resp <- Ok(joke) | |
| } yield resp | |
| } | |
| } | |
| def helloWorldRoutes[F[_]: Sync](H: HelloWorld[F]): HttpRoutes[F] = { | |
| val dsl = new Http4sDsl[F]{} | |
| import dsl._ | |
| HttpRoutes.of[F] { | |
| case GET -> Root / "hello" / name => | |
| for { | |
| greeting <- H.hello(HelloWorld.Name(name)) | |
| resp <- Ok(greeting) | |
| } yield resp | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment