diff options
author | Profpatsch <mail@profpatsch.de> | 2024-05-11T18·45+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-05-13T14·45+0000 |
commit | 8a6f12bdb93f0d603931d1278162aec55beb7765 (patch) | |
tree | ce51c1af696c387871aa6f0fb641a98e81d0b69f /users | |
parent | d119d07aaa3b7dec8cc2e1cde61e782dfaa0d422 (diff) |
refactor(users/Profpatsch/whatcd-resolver): inline hh r/8127
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
Diffstat (limited to 'users')
-rw-r--r-- | users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs index ad51b2edeed1..a233888c4529 100644 --- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs +++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs @@ -312,26 +312,24 @@ runHandlers :: (Wai.Response -> IO ResponseReceived) -> m ResponseReceived 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 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 = |