Skip to content

Commit

Permalink
Remove timeout middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
peel committed Sep 17, 2024
1 parent 2375edf commit e0145f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import org.http4s.{HttpApp, HttpRoutes}
import org.http4s.blaze.server.BlazeServerBuilder
import org.http4s.headers.`Strict-Transport-Security`
import org.http4s.server.Server
import org.http4s.server.middleware.{HSTS, Logger => LoggerMiddleware, Metrics, Timeout}
import org.http4s.server.middleware.{HSTS, Logger => LoggerMiddleware, Metrics}
import org.typelevel.ci.CIString
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger

import java.net.InetSocketAddress
import javax.net.ssl.SSLContext
import org.http4s.Response
import org.http4s.Status

object HttpServer {

Expand All @@ -47,7 +45,7 @@ object HttpServer {
): Resource[F, Server] =
for {
withMetricsMiddleware <- createMetricsMiddleware(routes, metricsConfig)
httpApp <- Resource.pure(httpApp(withMetricsMiddleware, healthRoutes, hsts, networking, debugHttp))
httpApp <- Resource.pure(httpApp(withMetricsMiddleware, healthRoutes, hsts, debugHttp))
server <- mkServer(httpApp, port, secure, networking)
} yield server

Expand All @@ -63,7 +61,6 @@ object HttpServer {
.withHttpApp(httpApp)
.withIdleTimeout(networking.idleTimeout)
.withMaxConnections(networking.maxConnections)
.withResponseHeaderTimeout(networking.responseHeaderTimeout)
.withLengthLimits(
maxRequestLineLen = networking.maxRequestLineLength,
maxHeadersLen = networking.maxHeadersLength
Expand All @@ -75,11 +72,10 @@ object HttpServer {
routes: HttpRoutes[F],
healthRoutes: HttpRoutes[F],
hsts: Config.HSTS,
networking: Config.Networking,
debugHttp: Config.Debug.Http
): HttpApp[F] = hstsApp(
hsts,
loggerMiddleware(timeoutMiddleware(routes, networking) <+> healthRoutes, debugHttp)
loggerMiddleware(routes <+> healthRoutes, debugHttp)
)

private def createMetricsMiddleware[F[_]: Async](
Expand Down Expand Up @@ -116,13 +112,6 @@ object HttpServer {
)(routes)
} else routes

private def timeoutMiddleware[F[_]: Async](routes: HttpRoutes[F], networking: Config.Networking): HttpRoutes[F] =
Timeout.httpRoutes[F](timeout = networking.responseHeaderTimeout)(routes).map {
case Response(Status.ServiceUnavailable, httpVersion, headers, body, attributes) =>
Response[F](Status.RequestTimeout, httpVersion, headers, body, attributes)
case response => response
}

implicit class ConditionalAction[A](item: A) {
def cond(cond: Boolean, action: A => A): A =
if (cond) action(item) else item
Expand Down

This file was deleted.

0 comments on commit e0145f7

Please sign in to comment.