php-http / message

HTTP Message related tools
http://php-http.org
MIT License
1.3k stars 42 forks source link

Base URL message factory #39

Closed jakzal closed 8 years ago

jakzal commented 8 years ago

Having to prefix all the calls with a base URL is annoying:

$factory->createRequest('GET', 'http://example.com/foo');

It could be avoided if we implemented something like the following that would include the base url for us:

$factory = new BaseUrlMessageFactory('http://example.com', new GuzzleMessageFactory());
$request = $factory->createRequest('GET', '/foo');

The advantage is that we wouldn't need to deal with base url in the place where the factory is used.

What do you think?

xabbuh commented 8 years ago

It looks like the AddHostPlugin does this job (it doesn't seem to have documentation right yet).

jakzal commented 8 years ago

Moreless ;) cheers!

sagikazarmark commented 8 years ago

Be aware of the way how PSR-7 describes URI trailing slashes a bit illogical IMO. See https://github.com/php-http/plugins/pull/42#issuecomment-171611857

jakzal commented 8 years ago

Actually, i'd love to be able to pass a string there :/