-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional test cases for Builder, Middleware
- Loading branch information
Showing
6 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Rougin\Slytherin\Middleware\Multiple; | ||
|
||
use Interop\Http\ServerMiddleware\DelegateInterface; | ||
use Interop\Http\ServerMiddleware\MiddlewareInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
/** | ||
* @package Slytherin | ||
* @author Rougin Gutib <rougingutib@gmail.com> | ||
*/ | ||
class Interop05 implements MiddlewareInterface | ||
{ | ||
/** | ||
* @param \Psr\Http\Message\ServerRequestInterface $request | ||
* @param \Interop\Http\ServerMiddleware\DelegateInterface $delegate | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function process(ServerRequestInterface $request, DelegateInterface $delegate) | ||
{ | ||
/** @var array<string, string> */ | ||
$parsed = $request->getParsedBody(); | ||
|
||
$response = $delegate->process($request); | ||
|
||
if (array_key_exists('name', $parsed)) | ||
{ | ||
$response = $response->withHeader('name', $parsed['name']); | ||
} | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Rougin\Slytherin\Middleware\Multiple; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use Rougin\Slytherin\Middleware\HandlerInterface; | ||
use Rougin\Slytherin\Middleware\MiddlewareInterface; | ||
|
||
/** | ||
* @package Slytherin | ||
* @author Rougin Gutib <rougingutib@gmail.com> | ||
*/ | ||
class Slytherin implements MiddlewareInterface | ||
{ | ||
/** | ||
* @param \Psr\Http\Message\ServerRequestInterface $request | ||
* @param \Rougin\Slytherin\Middleware\HandlerInterface $handler | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function process(ServerRequestInterface $request, HandlerInterface $handler) | ||
{ | ||
/** @var array<string, string> */ | ||
$parsed = $request->getParsedBody(); | ||
|
||
$parsed['name'] = 'Rougin Gutib'; | ||
|
||
$request = $request->withParsedBody($parsed); | ||
|
||
return $handler->handle($request); | ||
} | ||
} |