Fix http server startup

Closes: #2358
This commit is contained in:
eikek
2023-11-06 23:43:31 +01:00
parent 2ce6536d0b
commit a9b0c0e086
3 changed files with 65 additions and 27 deletions

View File

@ -58,24 +58,16 @@ object RestServer {
Stream(
restApp.subscriptions,
restApp.eventConsume(maxConcurrent = 2),
Stream.resource {
if (cfg.serverOptions.enableHttp2)
EmberServerBuilder
.default[F]
.withHost(cfg.bind.address)
.withPort(cfg.bind.port)
.withMaxConnections(cfg.serverOptions.maxConnections)
.withHttpWebSocketApp(createHttpApp(setting, pubSub, restApp))
.withHttp2
.build
else
EmberServerBuilder
.default[F]
.withHost(cfg.bind.address)
.withPort(cfg.bind.port)
.withMaxConnections(cfg.serverOptions.maxConnections)
.withHttpWebSocketApp(createHttpApp(setting, pubSub, restApp))
.build
Stream.eval {
EmberServerBuilder
.default[F]
.withHost(cfg.bind.address)
.withPort(cfg.bind.port)
.withMaxConnections(cfg.serverOptions.maxConnections)
.withHttpWebSocketApp(createHttpApp(setting, pubSub, restApp))
.toggleHttp2(cfg.serverOptions.enableHttp2)
.build
.useForever
}
)
}
@ -164,4 +156,9 @@ object RestServer {
).pure[F]
}
}
implicit final class EmberServerBuilderExt[F[_]](self: EmberServerBuilder[F]) {
def toggleHttp2(flag: Boolean) =
if (flag) self.withHttp2 else self.withoutHttp2
}
}