-
Previously I had this code: // ServerState is a custom class of mine
class ServerState { /* ... */ }
def getEndpoints(state: ServerState) =
foo(state) :+: bar(state) :+: baz(state) /* and many more */
def getCompiledOverallEndpoint(state: ServerState): Endpoint.Compiled[IO] = {
Bootstrap
.serve[Application.Json](getEndpoints(state))
.compile // ERROR: .compile doesn't exist
}
def getServiceForState(state: ServerState): Service[Request, Response] = {
val filters = Function.chain(Seq(exceptionLogging, logging))
Endpoint.toService(filters(getCompiledOverallEndpoint(state))) // ERROR: .toService doesn't exist
} However, after updating to finch 0.34.1 the PS: Have you thought about supplying a detailed changelog in this repository? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I think those changes are from 0.34.0: https://github.com/finagle/finch/releases/tag/v0.34.0 |
Beta Was this translation helpful? Give feedback.
-
You can call Bootstrap[IO]
.serve[Application.Json](getEndpoints(state))
.filter(Function.chain(Seq(exceptionLogging, logging)))
.toService And it returns a |
Beta Was this translation helpful? Give feedback.
-
Thanks! With How do I use the I've tried the code below, but the server never starts and the application immediately exits: class ServerState { /* ... */ }
object MyApp extends IOApp {
override def run(args: List[String]): IO[ExitCode] = {
val state = new ServerState(/* some initialization */)
createService(state).use(service => {
Http.serve(":8085", service)
IO.unit
})
IO.pure(ExitCode.Success)
}
private def createService(state: ServerState): effect.Resource[IO, Service[Request, Response]] = {
Bootstrap[IO]
.serve[Application.Json](getEndpoints(state))
.toService
}
private def getEndpoints(state: ServerState) = foo :+: bar :+: /* ... */
} |
Beta Was this translation helpful? Give feedback.
Perfect! It works now.
For future visitors, this is the final version of the code that's working: