Skip to content

Commit b232937

Browse files
authored
Merge pull request #40 from NthPortal/expose-generic-server-build
Expose method to build generic middleware
2 parents 21125a6 + 0a75389 commit b232937

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

core/src/main/scala/org/http4s/otel4s/middleware/ServerMiddleware.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,15 @@ object ServerMiddleware {
119119
def withDoNotTrace(doNotTrace: RequestPrelude => Boolean): ServerMiddlewareBuilder[F] =
120120
copy(doNotTrace = doNotTrace)
121121

122-
private def buildTracedF[G[_]: MonadCancelThrow](
122+
/** This method is used for building a middleware in a way that abstracts
123+
* over [[org.http4s.HttpApp `HttpApp`]] and
124+
* [[org.http4s.HttpRoutes `HttpRoutes`]]. In most cases, it is preferable
125+
* to use the methods that directly build the specific desired type.
126+
*
127+
* @see [[buildHttpApp]]
128+
* @see [[buildHttpRoutes]]
129+
*/
130+
def buildGenericTracedHttp[G[_]: MonadCancelThrow](
123131
f: Http[G, F]
124132
)(implicit kt: KindTransformer[F, G]): Http[G, F] =
125133
Kleisli { (req: Request[F]) =>
@@ -170,10 +178,10 @@ object ServerMiddleware {
170178
}
171179

172180
def buildHttpApp(f: HttpApp[F]): HttpApp[F] =
173-
buildTracedF(f)
181+
buildGenericTracedHttp(f)
174182

175183
def buildHttpRoutes(f: HttpRoutes[F]): HttpRoutes[F] =
176-
buildTracedF(f)
184+
buildGenericTracedHttp(f)
177185
}
178186

179187
private[middleware] def request[F[_]](

0 commit comments

Comments
 (0)