Giter VIP home page Giter VIP logo

Comments (7)

rymndhng avatar rymndhng commented on September 8, 2024

The example code you shared works really well 👍. Are you looking for contributions to get this into the repo?

from babashka.curl.

borkdude avatar borkdude commented on September 8, 2024

@rymndhng Yep, you can go ahead with a PR that implements this. To not break existing code, what would be a good option to state that you want a response map instead of only the body? Maybe something like (curl/get ... {:response true}) => {:headers .. :body .. :status ..}? Other ideas welcome.

cc @dainiusjocas

from babashka.curl.

dainiusjocas avatar dainiusjocas commented on September 8, 2024

The example code is naive and shouldn't very performant but for the first iteration might be good enough :)

from babashka.curl.

rymndhng avatar rymndhng commented on September 8, 2024

+1 on retaining the existing interface. The current API of returning stdout of the subprocess is appropriate given the ability to modify args with :raw-args.

To support response parsing, the change will involve modify the incoming opts property to add --I and transform the response. This to me hints the solution can be expressed elegantly with a middleware pattern.

With this in mind, perhaps we should consider adding a new namespace babashka.curl.client which works with response maps. This is similar to how cli-http organizes with cli-http.client as the higher level interface and cli-http.core as the lower level interface that translates to/from the java api.

from babashka.curl.

borkdude avatar borkdude commented on September 8, 2024

I'd rather focus on just the current feature:

Implement an option to get back the headers + body separately.

Also I'd rather keep this in one single namespace for now

from babashka.curl.

rymndhng avatar rymndhng commented on September 8, 2024

Fair point 👍

It occurred to me that the use-case for babashka.curl is just enough wrapping to be easy to work with. There are other libraries out there for the entire batteries-included http client.

from babashka.curl.

borkdude avatar borkdude commented on September 8, 2024

Yeah and we can always do middleware kind of stuff later on. To be honest, I've only used middleware once or twice with clj-http, so I'd say it won't be that common for scripting use cases.

from babashka.curl.

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.