Fix generation of optional query parameters

This commit is contained in:
Alex Biehl 2022-02-20 20:43:05 +01:00
parent 193bbe2226
commit c1c9b1fdb4
2 changed files with 4 additions and 3 deletions

View File

@ -331,12 +331,13 @@ codegenQueryParamGuard Param {name, required} continuation
) )
) )
| otherwise = | otherwise =
"case" <+> "fmap" <+> "(" <> "fmap" <+> "(" <> "Web.HttpApiData.parseUrlPiece" <+> "." <+> "Data.Text.Encoding.decodeUtf8" <> ")" <> ")" <+> "(" "case" <+> "Control.Monad.join" <+> "(" <> "fmap" <+> "(" <> "fmap" <+> "(" <> "Web.HttpApiData.parseUrlPiece" <+> "." <+> "Data.Text.Encoding.decodeUtf8" <> ")" <> ")" <+> "("
<> "Data.List.lookup" <+> "\"" <> "Data.List.lookup" <+> "\""
<> toParamName name <> toParamName name
<> "\"" <+> "(" <> "\"" <+> "("
<> "Network.Wai.queryString" <+> "request" <> "Network.Wai.queryString" <+> "request"
<> ")" <> ")"
<> ")"
<> ")" <+> "of" <> ")" <+> "of"
<> PP.line <> PP.line
<> PP.indent <> PP.indent

View File

@ -77,7 +77,7 @@ application run api notFound request respond =
Just (Left err) -> Just (Left err) ->
undefined undefined
Just (Right page) -> Just (Right page) ->
case fmap (fmap (Web.HttpApiData.parseUrlPiece . Data.Text.Encoding.decodeUtf8)) (Data.List.lookup "offset" (Network.Wai.queryString request)) of case Control.Monad.join (fmap (fmap (Web.HttpApiData.parseUrlPiece . Data.Text.Encoding.decodeUtf8)) (Data.List.lookup "offset" (Network.Wai.queryString request))) of
Just (Left err) -> Just (Left err) ->
undefined undefined
_x -> _x ->
@ -99,7 +99,7 @@ application run api notFound request respond =
Just (Left err) -> Just (Left err) ->
undefined undefined
Just (Right page) -> Just (Right page) ->
case fmap (fmap (Web.HttpApiData.parseUrlPiece . Data.Text.Encoding.decodeUtf8)) (Data.List.lookup "offset" (Network.Wai.queryString request)) of case Control.Monad.join (fmap (fmap (Web.HttpApiData.parseUrlPiece . Data.Text.Encoding.decodeUtf8)) (Data.List.lookup "offset" (Network.Wai.queryString request))) of
Just (Left err) -> Just (Left err) ->
undefined undefined
_x -> _x ->