Closed lthms closed 8 years ago
Do I understand correctly: servant has an implementation for FromHttpApiData String/Text and it does not encode with quotes there? That sucks.
I don't use plain strings as headers but my own data types - there it is easy to implement parseHeader with jsonParseHeader which is compatible with servant-purescript's encoding.
You can use this workaround in the meantime (if appropriate), while I am trying to find a good fix for this problem.
Should be fixed with version 3.0.1 of purescript-servant-support - please try and re-open if it does not work. Best regards, Robert
Thank you for your bug report and have a pleasant stay.
Thanks! I had a look, I fear a similar issue might happen with other prim types such as Int, for instance. Anyway, I will try it as soon as I come back home.
Numbers and bool should be fine. Here http-api-data is compatible with our JSON encoding. There is a default encoding for time, maybe and either which are incompatible - ok - I am going to need some more special cases.
I added a corresponding issue: https://github.com/eskimor/purescript-servant-support/issues/2
Great! Thanks a lot for that, I will try to help if I find something else (:
Okay so now I have another issue. 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.
Regarding the
Header
combinator, if its content is a String, Servant reads the raw string as far as I know. Hovewer, servant generated code call the settingsencodeURLPieces
(see https://github.com/eskimor/servant-purescript/blob/09548d56865c9f58b4e186e083fc923f34ac7f8f/src/Servant/PureScript/CodeGen.hs#L169)The example uses
gShow
(or I think I sawgDefaultEncodeURLPieces
or something), butgShow
adds quotes to a string. My string is a token, so you guess it is not a good idea to mess with token content…Do you have any idea on how we can fix that? One idée could be to add the
ToHttpApiData
type class to mimic Servant? Then change theGeneric a => a -> String
to the new typeclass? It might be less flexible, though.Thanks by advance!