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:
Profpatsch 2024-05-11 20:45:26 +02:00 committed by clbot
parent d119d07aaa
commit 8a6f12bdb9

View file

@ -312,13 +312,17 @@ runHandlers ::
(Wai.Response -> IO ResponseReceived) ->
m ResponseReceived
runHandlers defaultHandler handlers req respond = withRunInIO $ \runInIO -> do
let hh route act =
let path = [fmt|/{req & Wai.pathInfo & Text.intercalate "/"}|]
let handlerResponses =
( HandlerResponses
{ plain = (\m -> liftIO $ runInIO m >>= respond),
html = \act ->
Otel.inSpan'
[fmt|Route {route}|]
[fmt|Route {path}|]
( Otel.defaultSpanArguments
{ Otel.attributes =
HashMap.fromList
[ ("server.path", Otel.toAttribute @Text route)
[ ("server.path", Otel.toAttribute @Text path)
]
}
)
@ -326,12 +330,6 @@ runHandlers defaultHandler handlers req respond = withRunInIO $ \runInIO -> 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 handlerResponses =
( HandlerResponses
{ html = hh path,
plain = (\m -> liftIO $ runInIO m >>= respond)
}
)
let handler =