Fix Optional ReqBody' (wrap value into Maybe)
Closes #1346
Here is a small reproducible demonstration of the fix (requires Nix to run): https://gist.github.com/unclechu/77ec314b8651c0c17ea4ac486fdb9804
ReqBody' '[Optional, Strict] '[JSON] [Integer]
Is resolving to [Integer] in server serializer. This fix makes it become Maybe [Integer] instead (because it has Optional mode).
This PR brings these changes:
- Makes
OptionalReqBody'wrap it’s type intoMaybe - Request without headers and without payload resolves to
Nothing - Request with proper
Content-Typebut without payload resolves toNothing - When proper
Content-Typeheader is provided and payload is there it resolvesJustin case there were no parsing errors RequiredReqBody'behaves as usual (not affected by this fix)
I’m not certain about these two patterns:
(SFalse, STrue, False) -> return . either (const Nothing) (Just . Right)
(SFalse, SFalse, False) -> return . either (const Nothing) Just
But they seem to work as expected. It turned ouit that requests from the tests are having requestBodyLength request as KnownLength 0. I’m not sure why.
Hi!
Is there something keeping this from going upstream? I was under the impression this was the default behavior (that one would construct a custom type with '[Optional] to have optional request bodies like how Header works), but as pointed out that's not the case.
Yep', there is a conflict to be resolved in this PR. :)
@tchoutri I resolved the conflicts and rebased the change on top of latest master. Also I ran the tests locally with a successful result. Please have a look.
Is there anything we can do to help maintainers move this PR forward?
I somehow managed to miss the mention from 12 days ago. There could be a CI failure due to HsOpenSSL that I'm exploring in #1635, otherwise I don't have anything more to ask. :)
@unclechu okay, I believe that you should bump the version of HsOpenSSL used, reading its changelog: https://flora.pm/packages/%40hackage/HsOpenSSL/0.11.7.5/changelog
I'd like to see this PR merged - is there something I can do to help? I guess if I wanted to rebase it myself I'd have to open a separate PR?