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 =
"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" <+> "\""
<> toParamName name
<> "\"" <+> "("
<> "Network.Wai.queryString" <+> "request"
<> ")"
<> ")"
<> ")" <+> "of"
<> PP.line
<> PP.indent

View File

@ -77,7 +77,7 @@ application run api notFound request respond =
Just (Left err) ->
undefined
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) ->
undefined
_x ->
@ -99,7 +99,7 @@ application run api notFound request respond =
Just (Left err) ->
undefined
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) ->
undefined
_x ->