httpful icon indicating copy to clipboard operation
httpful copied to clipboard

Current implementation of templates is designed to fail

Open BlaM opened this issue 9 years ago • 3 comments

I like httpful, but there is one component that makes using the whole library feel itchy: The current implementation of templates is designed to fail as soon as you use httpful to communicate with more than one API: Templates are "global".

Scenario:

  • Two APIs. We try to connect to both of them through httpful.
  • Before calling API A we use the templating system to modify some defaults.
  • We call API A - everything works as expected
  • Then we call API B.
  • Everything explodes because the defaults from API A don't fit.

Instead of

Request::ini($template);

wouldn't it be better to have something like

$r = Request::get($url)->using($template)->...

?

BlaM avatar Apr 20 '15 11:04 BlaM

I agree here. The next major revision of the library will get away from much of the static global state, in particular when it comes to templates.

nategood avatar Sep 19 '15 20:09 nategood

Hi! great suggestion, any news on the implementation? any alternative solution meanwhile?

apuredol avatar Nov 23 '16 19:11 apuredol

Yes. I agree this is a major short coming. I identified this as the primary goal for the next major release. On Wed, Nov 23, 2016 at 2:16 PM Raul Plata [email protected] wrote:

Hi! great suggestion, any news on the implementation? any alternative solution meanwhile?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nategood/httpful/issues/175#issuecomment-262606606, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJaA6ovuBcXj-S7oXWB7oU_UYNH3KHnks5rBJEWgaJpZM4EEOYZ .

nategood avatar Dec 10 '16 19:12 nategood