refactor(users/Profpatsch/whatcd-resolver): inline hh
Change-Id: I70ea1d7cb17e7ac7bf63be86b79d2f0b79586912 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11646 Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
d119d07aaa
commit
8a6f12bdb9
1 changed files with 15 additions and 17 deletions
|
@ -312,26 +312,24 @@ runHandlers ::
|
||||||
(Wai.Response -> IO ResponseReceived) ->
|
(Wai.Response -> IO ResponseReceived) ->
|
||||||
m ResponseReceived
|
m ResponseReceived
|
||||||
runHandlers defaultHandler handlers req respond = withRunInIO $ \runInIO -> do
|
runHandlers defaultHandler handlers req respond = withRunInIO $ \runInIO -> do
|
||||||
let hh route act =
|
|
||||||
Otel.inSpan'
|
|
||||||
[fmt|Route {route}|]
|
|
||||||
( Otel.defaultSpanArguments
|
|
||||||
{ Otel.attributes =
|
|
||||||
HashMap.fromList
|
|
||||||
[ ("server.path", Otel.toAttribute @Text route)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
( \span -> do
|
|
||||||
res <- act span <&> (\html -> T2 (label @"html" html) (label @"extraHeaders" []))
|
|
||||||
liftIO $ respond . Wai.responseLBS Http.ok200 ([("Content-Type", "text/html")] <> res.extraHeaders) . Html.renderHtml $ res.html
|
|
||||||
)
|
|
||||||
|
|
||||||
let path = [fmt|/{req & Wai.pathInfo & Text.intercalate "/"}|]
|
let path = [fmt|/{req & Wai.pathInfo & Text.intercalate "/"}|]
|
||||||
let handlerResponses =
|
let handlerResponses =
|
||||||
( HandlerResponses
|
( HandlerResponses
|
||||||
{ html = hh path,
|
{ plain = (\m -> liftIO $ runInIO m >>= respond),
|
||||||
plain = (\m -> liftIO $ runInIO m >>= respond)
|
html = \act ->
|
||||||
|
Otel.inSpan'
|
||||||
|
[fmt|Route {path}|]
|
||||||
|
( Otel.defaultSpanArguments
|
||||||
|
{ Otel.attributes =
|
||||||
|
HashMap.fromList
|
||||||
|
[ ("server.path", Otel.toAttribute @Text path)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
( \span -> do
|
||||||
|
res <- act span <&> (\html -> T2 (label @"html" html) (label @"extraHeaders" []))
|
||||||
|
liftIO $ respond . Wai.responseLBS Http.ok200 ([("Content-Type", "text/html")] <> res.extraHeaders) . Html.renderHtml $ res.html
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
let handler =
|
let handler =
|
||||||
|
|
Loading…
Reference in a new issue