Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement HasForeign instance #1035

Merged
merged 3 commits into from
Nov 7, 2018

Conversation

afcady
Copy link

@afcady afcady commented Sep 17, 2018

This is three patches, to servant-foreign, servant-multipart, and servant-js.

https://github.com/haskell-servant/servant-multipart/compare/master...afcady:multipart-foreign?expand=1

https://github.com/haskell-servant/servant/compare/master...afcady:multipart-foreign?expand=1

https://github.com/haskell-servant/servant-js/compare/master...afcady:multipart-foreign?expand=1

The patch to servant-foreign adds a Boolean field to the Req type specifying whether the request body is JSON (as is currently assumed). The patch to servant-multipart implements a HasForeign instance that sets this field to False. The patch to servant-js changes the output of vanillaJS when the flag is false, so that JSON.stringify() does not get called on the body and the content-type is not set to JSON.

This address haskell-servant/servant-multipart#5

This is needed for servant-js to know whether to call JSON.stringify()
on the request body or just send it raw.
@afcady
Copy link
Author

afcady commented Sep 21, 2018

Look OK now?

Copy link
Contributor

@alpmestan alpmestan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would have something more general to support more content types, but let's roll with this for now as I don't have a brillant idea to make the supported content type list open-ended.

@phadej phadej merged commit 80a047d into haskell-servant:master Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants