Giter Club home page Giter Club logo

Comments (3)

whoshuu avatar whoshuu commented on May 21, 2024

You're actually right, there's no way to upload raw data with POST/PUT/PATCH. This is an oversight, I'll have to get this down in 1.2, but it'll be pretty high priority. In the meantime, there is a way to set the content-type, but it requires you to go through the header. You have to add a Header{{"content-type"}, {"application/json"}} to your request call.

While we're on the subject, what are your thoughts on providing a json library (I'm thinking Niels Lohmann's library)? This would let me do things like accept a Json object and set the header automatically.

from cpr.

whoshuu avatar whoshuu commented on May 21, 2024

For now, I'm going to limit the scope of this to just providing an API for setting a raw data type for a request.

from cpr.

niklas88 avatar niklas88 commented on May 21, 2024

I personally think that adding json is out of the scope of a HTTP library. Honestly I'm a big fan of the HTTP package of Go https://golang.org/pkg/net/http/ (by the way that implements all of HTTP itself and I find it to be pretty clean too) and that's also pretty clear on staying in the HTTP realm.

Also when cpr supports raw bodys either with it's own Body type or directly as string (this should probably be kept in sync with response.text / response.body) using json with it is absolutely trivial so the gain in my opinion isn't too big.

from cpr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.