BrandonRomano / wrecker

A golang request builder for JSON APIs
MIT License
24 stars 0 forks source link

Add function to set ContentType at request level #15

Open BrandonRomano opened 9 years ago

BrandonRomano commented 9 years ago

Realized in #14 we should probably add this.

Probably ContentType would be a good function name for this.

benpate commented 9 years ago

I think Wrecker should be able to determine the default content type based on the parameters that have been included. For example, if there's a BODY, then set the Content-Type to "application/json". Otherwise, set it to "x-www-form-encoded". Then, this could be overridden by the new function .ContentType()

Once we get to executing the request, we can switch on the Content-Type to choose the encoder (Form, JSON, or XML)

EDIT: This means that we could probably remove the DefaultContentType property on the Wrecker object. It should be simple enough to determine that from the properties of each request.

BrandonRomano commented 9 years ago

Okay, yeah I agree... Let's do that!

BrandonRomano commented 9 years ago

Hey @benpate I've updated this issue's description to match what we want to do with this now.