Skip to content

Commit

Permalink
updated http-middleware interface to 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 22, 2016
1 parent fd1f0e3 commit 357a829
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 0.2.0 - 2016-11-22

### Changed

* Updated to `http-interop/http-middleware#0.3`

## 0.1.1 - 2016-10-02

### Fixed
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# middlewares/base-path

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Software License][ico-license]](LICENSE)
[![Build Status][ico-travis]][link-travis]
[![Quality Score][ico-scrutinizer]][link-scrutinizer]
[![Total Downloads][ico-downloads]][link-downloads]
[![SensioLabs Insight][ico-sensiolabs]][link-sensiolabs]

Middleware to remove the prefix from the uri path of the request. This is useful to combine with routers if the root of the website is in a subdirectory. For example, if the root of your website is `/web/public`, a request with the uri `/web/public/post/34` will be converted to `/post/34`.

**Note:** This middleware is intended for server side only

## Requirements

* PHP >= 5.6
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
},
"require": {
"php": "^5.6 || ^7.0",
"http-interop/http-middleware": "^0.2",
"middlewares/utils": "0.*"
"http-interop/http-middleware": "^0.3",
"middlewares/utils": "~0.5"
},
"require-dev": {
"phpunit/phpunit": "^5.5",
"zendframework/zend-diactoros": "^1.3",
"friendsofphp/php-cs-fixer": "^1.12",
"squizlabs/php_codesniffer": "^2.7",
"mindplay/middleman": "^2.0"
"squizlabs/php_codesniffer": "^2.7"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 4 additions & 3 deletions tests/BasePathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
namespace Middlewares\Tests;

use Middlewares\BasePath;
use Middlewares\Utils\Dispatcher;
use Middlewares\Utils\CallableMiddleware;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\Response;
use mindplay\middleman\Dispatcher;

class BasePathTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -61,12 +62,12 @@ public function testBasePath($basePath, $uri, $result, $location)
$response = (new Dispatcher([
(new BasePath($basePath))->fixLocation(),

function ($request) {
new CallableMiddleware(function ($request) {
$response = new Response();
$response->getBody()->write((string) $request->getUri()->getPath());

return $response->withHeader('Location', (string) $request->getUri());
},
}),
]))->dispatch($request);

$this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
Expand Down

0 comments on commit 357a829

Please sign in to comment.