Skip to content

Commit 43927e8

Browse files
committed
feat(http): add X-Response-Time header to response
1 parent c162993 commit 43927e8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/main/scala/net/yoshinorin/qualtet/BootStrap.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import net.yoshinorin.qualtet.http.routes.{
2626
import net.yoshinorin.qualtet.http.routes.CacheRoute
2727
import org.http4s.ember.server.EmberServerBuilder
2828
import com.comcast.ip4s.*
29+
import org.http4s.server.middleware.ResponseTiming
2930

3031
// import scala.io.StdIn
3132

@@ -74,8 +75,11 @@ object BootStrap extends IOApp {
7475

7576
Modules.migrator.migrate(Modules.contentTypeService)
7677

78+
// NOTE: https://github.com/http4s/http4s/blob/v1.0.0-M40/server/shared/src/main/scala/org/http4s/server/middleware/ResponseTiming.scala
79+
// https://github.com/http4s/http4s/blob/v1.0.0-M40/server/shared/src/main/scala/org/http4s/server/middleware/ResponseLogger.scala
80+
val responseTiming = ResponseTiming(router.routes)
7781
// TODO: filter & format log
78-
val httpAppWithLogger: HttpApp[IO] = Logger.httpApp(true, false)(router.routes)
82+
val httpAppWithLogger: HttpApp[IO] = Logger.httpApp(logHeaders = true, logBody = false)(responseTiming)
7983

8084
val host = Ipv4Address.fromString(Modules.config.http.host).getOrElse(ipv4"127.0.0.1")
8185
val port = Port.fromInt(Modules.config.http.port).getOrElse(port"9001")

0 commit comments

Comments
 (0)