From c0a4983e875e663e51e32ee56e3b640152bf6003 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 18 Jul 2024 09:14:56 +0100 Subject: [PATCH] ;dev: web: refactor --- hledger-web/Hledger/Web/WebOptions.hs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/hledger-web/Hledger/Web/WebOptions.hs b/hledger-web/Hledger/Web/WebOptions.hs index a3ea1617b..b9e15a38e 100644 --- a/hledger-web/Hledger/Web/WebOptions.hs +++ b/hledger-web/Hledger/Web/WebOptions.hs @@ -152,17 +152,18 @@ rawOptsToWebOpts :: RawOpts -> IO WebOpts rawOptsToWebOpts rawopts = checkWebOpts <$> do cliopts <- rawOptsToCliOpts rawopts - let h = fromMaybe defhost $ maybestringopt "host" rawopts - p = fromMaybe defport $ maybeposintopt "port" rawopts - b = maybe (defbaseurl h p) stripTrailingSlash $ maybestringopt "base-url" rawopts - sock = stripTrailingSlash <$> maybestringopt "socket" rawopts - access = - case lastMay $ listofstringopt "allow" rawopts of - Nothing -> AddAccess - Just t -> - case parseAccessLevel t of - Right al -> al - Left err -> error' ("Unknown access level: " ++ err) -- PARTIAL: + let + h = fromMaybe defhost $ maybestringopt "host" rawopts + p = fromMaybe defport $ maybeposintopt "port" rawopts + b = maybe (defbaseurl h p) stripTrailingSlash $ maybestringopt "base-url" rawopts + sock = stripTrailingSlash <$> maybestringopt "socket" rawopts + access = + case lastMay $ listofstringopt "allow" rawopts of + Nothing -> AddAccess + Just t -> + case parseAccessLevel t of + Right al -> al + Left err -> error' ("Unknown access level: " ++ err) -- PARTIAL: return defwebopts { serve_ = case sock of