I have a legacy product that's using http4s 0.8 version. I'm trying to do an incremental upgrade and the best version I could upgrade is 0.15.16.
Currently I could use following syntax
service1 orElse service2 orElse
But in 0.15.16 orElse
is not available and I'm not sure how could I concat multiple http service.
Code sample
object Test {
val db = MySQLAdapter(url = "jdbc:mysql:///test?useSSL=false", user = "service", password = "")
val userDao = UserDao(db)
}
object HealthApi extends ResponseCodec with BooleanCodec {
def service =
HttpService {
case GET -> Root / "ping" => true
}
}
object Main extends ServerApp with ResponseCodec with TimestampCodec {
def service: HttpService = HttpService {
case GET -> Root / "hello" / name => s"Hello $name"
case GET -> Root / "user" => Test.userDao.testUser("admin@exam.com")
}
def server(args: List[String]): Task[Server] =
BlazeBuilder
.withNio2(true)
.bindHttp(8080)
.mountService(service, "/api")
.start
}
FYI: How to combine AuthedRoutes and HttpRoutes in http4s? didn't help