mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-28 01:35:06 +00:00
Merge pull request #2338 from rehanone/update-http4s-server
Replace `http4s-blaze-server` with `http4s-ember-server`.
This commit is contained in:
commit
c9ebd15b23
@ -802,6 +802,7 @@ val joex = project
|
||||
Dependencies.http4sDsl ++
|
||||
Dependencies.circe ++
|
||||
Dependencies.pureconfig ++
|
||||
Dependencies.pureconfigIp4s ++
|
||||
Dependencies.emilTnef ++
|
||||
Dependencies.poi ++
|
||||
Dependencies.emilMarkdown ++
|
||||
@ -859,6 +860,7 @@ val restserver = project
|
||||
Dependencies.http4sDsl ++
|
||||
Dependencies.circe ++
|
||||
Dependencies.pureconfig ++
|
||||
Dependencies.pureconfigIp4s ++
|
||||
Dependencies.yamusca ++
|
||||
Dependencies.kittens ++
|
||||
Dependencies.webjars,
|
||||
|
@ -27,6 +27,8 @@ import docspell.pubsub.naive.PubSubConfig
|
||||
import docspell.scheduler.{PeriodicSchedulerConfig, SchedulerConfig}
|
||||
import docspell.store.{JdbcConfig, SchemaMigrateConfig}
|
||||
|
||||
import com.comcast.ip4s.{Host, Port}
|
||||
|
||||
case class Config(
|
||||
appId: Ident,
|
||||
baseUrl: LenientUri,
|
||||
@ -59,7 +61,7 @@ case class Config(
|
||||
}
|
||||
|
||||
object Config {
|
||||
case class Bind(address: String, port: Int)
|
||||
case class Bind(address: Host, port: Port)
|
||||
|
||||
case class ScanMailbox(maxFolders: Int, mailChunkSize: Int, maxMails: Int) {
|
||||
def mailBatchSize: Int =
|
||||
|
@ -18,6 +18,7 @@ import emil.MailAddress
|
||||
import emil.javamail.syntax._
|
||||
import pureconfig._
|
||||
import pureconfig.generic.auto._
|
||||
import pureconfig.module.ip4s._
|
||||
import yamusca.imports._
|
||||
|
||||
object ConfigFile {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
package docspell.joex
|
||||
|
||||
import cats.effect.Ref
|
||||
import cats.effect._
|
||||
import fs2.Stream
|
||||
import fs2.concurrent.SignallingRef
|
||||
@ -19,8 +18,8 @@ import docspell.store.Store
|
||||
import docspell.store.records.RInternalSetting
|
||||
|
||||
import org.http4s.HttpApp
|
||||
import org.http4s.blaze.server.BlazeServerBuilder
|
||||
import org.http4s.ember.client.EmberClientBuilder
|
||||
import org.http4s.ember.server.EmberServerBuilder
|
||||
import org.http4s.implicits._
|
||||
import org.http4s.server.Router
|
||||
import org.http4s.server.middleware.Logger
|
||||
@ -70,13 +69,15 @@ object JoexServer {
|
||||
|
||||
Stream
|
||||
.resource(app)
|
||||
.flatMap(app =>
|
||||
BlazeServerBuilder[F]
|
||||
.bindHttp(cfg.bind.port, cfg.bind.address)
|
||||
.withHttpApp(app.httpApp)
|
||||
.withoutBanner
|
||||
.serveWhile(app.termSig, app.exitRef)
|
||||
)
|
||||
|
||||
.flatMap { app =>
|
||||
Stream.resource {
|
||||
EmberServerBuilder
|
||||
.default[F]
|
||||
.withHost(cfg.bind.address)
|
||||
.withPort(cfg.bind.port)
|
||||
.withHttpApp(app.httpApp)
|
||||
.build
|
||||
}
|
||||
}
|
||||
}.drain
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import docspell.restserver.Config.{DownloadAllCfg, OpenIdConfig, ServerOptions}
|
||||
import docspell.restserver.auth.OpenId
|
||||
import docspell.restserver.http4s.InternalHeader
|
||||
|
||||
import com.comcast.ip4s.IpAddress
|
||||
import com.comcast.ip4s.{Host, IpAddress, Port}
|
||||
|
||||
case class Config(
|
||||
appName: String,
|
||||
@ -63,7 +63,7 @@ object Config {
|
||||
enableHttp2: Boolean,
|
||||
maxConnections: Int
|
||||
)
|
||||
case class Bind(address: String, port: Int)
|
||||
case class Bind(address: Host, port: Port)
|
||||
|
||||
case class AdminEndpoint(secret: String)
|
||||
|
||||
|
@ -21,6 +21,7 @@ import docspell.store.Db
|
||||
|
||||
import pureconfig._
|
||||
import pureconfig.generic.auto._
|
||||
import pureconfig.module.ip4s._
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
object ConfigFile {
|
||||
|
@ -24,9 +24,9 @@ import docspell.store.Store
|
||||
import docspell.store.records.RInternalSetting
|
||||
|
||||
import org.http4s._
|
||||
import org.http4s.blaze.server.BlazeServerBuilder
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.http4s.ember.client.EmberClientBuilder
|
||||
import org.http4s.ember.server.EmberServerBuilder
|
||||
import org.http4s.headers.Location
|
||||
import org.http4s.implicits._
|
||||
import org.http4s.server.Router
|
||||
@ -56,20 +56,27 @@ object RestServer {
|
||||
Stream(
|
||||
restApp.subscriptions,
|
||||
restApp.eventConsume(2),
|
||||
BlazeServerBuilder[F]
|
||||
.bindHttp(cfg.bind.port, cfg.bind.address)
|
||||
.withoutBanner
|
||||
.withResponseHeaderTimeout(cfg.serverOptions.responseTimeout.toScala)
|
||||
.enableHttp2(cfg.serverOptions.enableHttp2)
|
||||
.withMaxConnections(cfg.serverOptions.maxConnections)
|
||||
.withHttpWebSocketApp(
|
||||
createHttpApp(setting, pubSub, restApp)
|
||||
)
|
||||
.serve
|
||||
.drain
|
||||
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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
exit <-
|
||||
(server ++ Stream(keepAlive)).parJoinUnbounded.compile.drain.as(ExitCode.Success)
|
||||
} yield exit
|
||||
|
@ -20,7 +20,7 @@ import org.typelevel.ci.CIString
|
||||
object ClientRequestInfo {
|
||||
|
||||
def getBaseUrl[F[_]](cfg: Config, req: Request[F]): LenientUri =
|
||||
if (cfg.baseUrl.isLocal) getBaseUrl(req, cfg.bind.port).getOrElse(cfg.baseUrl)
|
||||
if (cfg.baseUrl.isLocal) getBaseUrl(req, cfg.bind.port.value).getOrElse(cfg.baseUrl)
|
||||
else cfg.baseUrl
|
||||
|
||||
private def getBaseUrl[F[_]](req: Request[F], serverPort: Int): Option[LenientUri] =
|
||||
|
@ -251,7 +251,7 @@ object Dependencies {
|
||||
)
|
||||
|
||||
val http4sServer = Seq(
|
||||
"org.http4s" %% "http4s-blaze-server" % "0.23.14"
|
||||
"org.http4s" %% "http4s-ember-server" % Http4sVersion
|
||||
)
|
||||
|
||||
val circeCore = Seq(
|
||||
@ -277,6 +277,10 @@ object Dependencies {
|
||||
"com.github.pureconfig" %% "pureconfig" % PureConfigVersion
|
||||
)
|
||||
|
||||
val pureconfigIp4s = Seq(
|
||||
"com.github.pureconfig" %% "pureconfig-ip4s" % PureConfigVersion
|
||||
)
|
||||
|
||||
// https://github.com/h2database/h2database
|
||||
// MPL 2.0 or EPL 1.0
|
||||
val h2 = Seq(
|
||||
|
Loading…
x
Reference in New Issue
Block a user