Giter Site home page Giter Site logo

Comments (4)

Sammyjo20 avatar Sammyjo20 commented on May 22, 2024 3

Hi @simonhamp, thank you for your comments, I really appreciate it!

I'll start off with saying I really like this idea. I don't know a huge amount about PSR-7 (I think is the right PSR) but I do know that Guzzle follows it quite well. I'd like in the future to be able to make swappable clients for Saloon so you can easily build your own Saloon clients/adapters that it uses under the hood.

The main request flow for Saloon is as follows:

  1. Request is created and sent method is called
  2. Request goes to request manager
  3. RequestManager builds up and merges headers, config, interceptors and handlers defined on both the request and the connector
  4. RequestManager converts it to a Guzzle response
  5. Guzzle sends the request
  6. Saloon receives the response
  7. Saloon sends you the response

I think Saloon could replace the RequestManager with a SaloonClient, with the default being GuzzleClient. Inside of the client, it would be responsible for building up the request, but it would have access to:

  • All the merged headers, config, handlers and interceptors
  • The request URL
  • The ability to create a Saloon response

That way, you would be able to create any client you like and apply the headers/config/handlers in whichever way the client supports it. If a particular client didn't support middleware/handlers like Guzzle does, maybe you can specify that in the client so Saloon would know to disable that particular feature.

What are your thoughts?

I feel that this would take Saloon to the next level, from being a Guzzle wrapper to being the "Flysystem" of HTTP integrations. As exciting as this is, I'm happy to leave it dependant on Guzzle for the next few months at least, because it's really solid so far, and then as it matures I hope to use this client pattern. I've got a couple of things I want to build in Saloon first like mocking and caching. Once I've built that - I'll say Saloon is ready for version 1.0, after that I'll look into making it pluggable.

from saloon.

simonhamp avatar simonhamp commented on May 22, 2024 1

Totally agree! Only build it if/when it's needed.

Regardless, I'm looking forward to using this package soon

from saloon.

Sammyjo20 avatar Sammyjo20 commented on May 22, 2024

Sounds great! I’ll happily keep this issue open for now so others can know it’s on my mind.

Hope you have fun with it!

from saloon.

Sammyjo20 avatar Sammyjo20 commented on May 22, 2024

I will convert this into a discussion to move it away from the issues page πŸš€

from saloon.

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.