purescript-contrib/purescript-affjax

Investigate setting Content-Type header based on Requestable type

garyb opened this issue · 2 comments

Mainly just need to figure out how to deal with boundaries for multipart/form-data.

I think to make this work we'll have to go with:

class Requestable a where
  requestType :: a -> MimeType
  toRequest :: a -> RequestContent

That way requestType can use information about the content to construct things like the form data boundaries, charset, etc. Originally I had intended to use Proxy a as the requestType input, but I guess we don't need the Proxy in there, as unlike with Responsable we will actually have an a value at request time.

Maybe you could do something like:

class Requestable a where
  toRequest :: a -> Tuple a RequestContent

Just to clean it up a bit?