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

http-api-data default encodings for primitive types need to be handled #2

Open
eskimor opened this issue Sep 20, 2016 · 1 comment
Open

Comments

@eskimor
Copy link
Owner

eskimor commented Sep 20, 2016

Because we at servant-purescript are lazy people we just use a url-encoded JSON default encoding for headers, path pieces and queries. This works well for simple types or if you don't care about the looks.

Unfortunately http-api-data has a few default encodings which are incompatible.

So if you are using:

  • Time
  • Maybe
  • Either

directly (not contained in a user defined type) for headers, urlpieces,.. - you are doomed.

Just kidding - a workaround is easy: Use a newtype wrapper and implement the http-api-data yourself using the helpers defined in Servant.Purescript.

This is related to servant-purescript#6, but even if user's can't yet customize the used encoding they should at least get a default encoding that works in all cases.

A special case for String/Text is already implemented, we need similar rules for the other types.

As usual, as I am super busy - any help would be appreciated. If you stumble upon making use of those types - please consider adding a special rule for your type and make sure it works for your application.

@lthms
Copy link

lthms commented Sep 20, 2016

Okay so probably this is a better spot to talk about it.

I still have an issue with Strings. It works well for alphanumeric chars, but for special ones… not so much. Indeed, if my String contains a special character, such as / or +, they are translated into %20 or whatever (I do not remember the exact numbers).

I am still searching in the purescript-servant-support the reason of this.

Edit: Oh. It is because you are calling encodeToURLPieces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants