New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature middlewares #23
Conversation
… basic middlewares
d97a4fa
to
689e52e
Compare
ad9e24b
to
bdf6e04
Compare
7aa300a
to
3433444
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add more scalar type hints where possible for consistency.
Align key value pairs over the whole project for consistency.
*/ | ||
public function __invoke(callable $handler) | ||
{ | ||
return (function (RequestInterface $request, array $options) use ($handler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very hard to read, can this possibly be simplified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. This is basically the regular implementation of guzzle middlewares: http://docs.guzzlephp.org/en/latest/handlers-and-middleware.html#middleware
I made this class to make it easy to implement your own middleware, but the complexity has to be placed somewhere.
{ | ||
$request = new Request('/', 'POST', 'php://temp', ['x-request-header' => 'value']); | ||
$request->getBody()->write('REQUESTBODY'); | ||
$respone = new Response('php://memory', 200, ['x-response-header' => 'value']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo respone -> response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
function it_can_load_from_psr7_request_and_response_without_body() | ||
{ | ||
$request = new Request('/', 'GET', 'php://temp', ['x-request-header' => 'value']); | ||
$respone = new Response('php://memory', 204, ['x-response-header' => 'value']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
$soapClient->setHandler($this->handler); | ||
} | ||
|
||
if (count($this->middlewares)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this condition be combined, and the foreach out of the if statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree on your argument. I've just changed it, but it was more readible as it is right now. I'll keep this one AS-IS for now.
/** | ||
* @var string | ||
*/ | ||
private $privateKeyFile = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why assign an empty string?
This param is required in the constructor.
|
||
$xml = SoapXml::fromStream($response->getBody()); | ||
$wsse = new WSSESoap($xml->getXmlDocument()); | ||
$wsse->decryptSoapDoc($xml->getXmlDocument(), [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align k/v pairs (formatting)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
foreach ($this->prepareHeaders() as $name => $value) { | ||
$request = $request->withHeader($name, $value); | ||
} | ||
} catch (\InvalidArgumentException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use it, don't use fqcn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* @var RequestFactoryInterface | ||
*/ | ||
private $requestFactory; | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newline for max style points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
/** | ||
* SOSPAction header is removed in SOAP 1.2 and now expressed as a value of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
Also the link doesn't work for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
*/ | ||
class SoapXml | ||
{ | ||
const XMLNS_XMLNS = 'http://www.w3.org/2000/xmlns/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit weird, is this by design?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is by design: The XLMNS of alias XMLNS is the url.
This way, you can e.g. also add: XMLNS_WSA = 'url';
in a future version.
Thanks for the review @janvernieuwe. It feels like it's quite ready to ship! :) |
This PR adds middleware support to the soap-client so that it is easy to configure extensions.
More information can be found in #21.
Task list:
Knows limitations: