Coder Social home page Coder Social logo

HTTP about script HOT 5 CLOSED

bitfield avatar bitfield commented on August 24, 2024
HTTP

from script.

Comments (5)

bitfield avatar bitfield commented on August 24, 2024 2

Done (at last!) in #139, and thanks to everyone here for their valuable input in hashing out this design.

from script.

earthboundkid avatar earthboundkid commented on August 24, 2024

What if the API were func HTTP(baseurl string, options ...HTTPOptions) *Pipe? HTTPOptions could default to GET, reject non-2XX, no special headers, no body, but let users provide those by passing in options. For things like users wanting to get the status code there could be a generic callback options like func HTTPHandler(func (*http.Response, *http.Request) error) HTTPOption to let users do whatever post-processing before the pipe that they want.

from script.

bitfield avatar bitfield commented on August 24, 2024

That's nice, but the addition of options makes it extremely complicated. In general, script is designed to help you quickly write concise programs that do fairly simple things. It's assumed that in the complicated case you won't mind writing normal Go code, which is very good at that kind of thing.

I'd like to try out a few ideas for HTTP support and kick the tyres on them a bit, to see how much of the common use cases they cover without options.

from script.

M3talM0nk3y avatar M3talM0nk3y commented on August 24, 2024

Hey @bitfield @carlmjohnson, I submitted PR-136 and wanted to see if this should do. This currently supports GET requests but I can extend it to support all other HTTP Verbs, authentication, etc.

Here's an example request -
statusCode, body, err := script.Http("https://postman-echo.com/get?foo1=bar1&foo2=bar2").Get()

Looking forward to your feedback.

from script.

bitfield avatar bitfield commented on August 24, 2024

Thanks, @M3talM0nk3y! How do you see this integrating with the other pipe-based operations in script? For example, how would you pipe the HTTP response into a JQ query?

from script.

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.