PHPackages                             wyrihaximus/react-http-contextual-middleware-runner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. wyrihaximus/react-http-contextual-middleware-runner

ActiveLibrary[HTTP &amp; Networking](/categories/http)

wyrihaximus/react-http-contextual-middleware-runner
===================================================

Run a set of react/http middleware when a context checker passes

1.0.0(7y ago)09611[3 PRs](https://github.com/WyriHaximus/reactphp-http-contextual-middleware-runner/pulls)MITPHPPHP ^7.2CI failing

Since Jul 10Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/reactphp-http-contextual-middleware-runner)[ Packagist](https://packagist.org/packages/wyrihaximus/react-http-contextual-middleware-runner)[ RSS](/packages/wyrihaximus-react-http-contextual-middleware-runner/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (6)Versions (5)Used By (0)

Run a set of react/http middleware when a context checker passes
================================================================

[](#run-a-set-of-reacthttp-middleware-when-a-context-checker-passes)

[![Build Status](https://camo.githubusercontent.com/f7b719a8640477a833485ec8ea69429286e051c0e36ccdc7ba4f42bd7ea7c267/68747470733a2f2f7472617669732d63692e636f6d2f57797269486178696d75732f72656163747068702d687474702d636f6e7465787475616c2d6d6964646c65776172652d72756e6e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/WyriHaximus/reactphp-http-contextual-middleware-runner)[![Latest Stable Version](https://camo.githubusercontent.com/4b20a782505c13da804eeeef460874a2e156bc4e98cf0486c89b17c57dbbceb0/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d687474702d636f6e7465787475616c2d6d6964646c65776172652d72756e6e65722f762f737461626c652e706e67)](https://packagist.org/packages/WyriHaximus/react-http-contextual-middleware-runner)[![Total Downloads](https://camo.githubusercontent.com/761045b650f22bff9b1c24001c48e6cfde8249506b41804292b849163a745ebe/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d687474702d636f6e7465787475616c2d6d6964646c65776172652d72756e6e65722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/WyriHaximus/react-http-contextual-middleware-runner)[![Code Coverage](https://camo.githubusercontent.com/52353bfedc3e3c72f4d4063e52f96b718d1c6060fd965f3e66a4e0096f6dd4c7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f57797269486178696d75732f72656163747068702d687474702d636f6e7465787475616c2d6d6964646c65776172652d72756e6e65722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-http-contextual-middleware-runner/?branch=master)[![License](https://camo.githubusercontent.com/9699abcdc2826229c075cc2e6df7d3b1be099ad53df5647ab0540a0a01004477/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d687474702d636f6e7465787475616c2d6d6964646c65776172652d72756e6e65722f6c6963656e73652e706e67)](https://packagist.org/packages/WyriHaximus/react-http-contextual-middleware-runner)[![PHP 7 ready](https://camo.githubusercontent.com/42718cddeb81248571079e9a79343ed0f98fbc659d6f1cf0bbf642e84f6d6cbf/687474703a2f2f7068703772656164792e74696d6573706c696e7465722e63682f57797269486178696d75732f72656163747068702d687474702d6d6964646c65776172652d636c6561722d626f64792f62616467652e737667)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-clear-body)

Install
=======

[](#install)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require wyrihaximus/react-http-contextual-middleware-runner

```

This middleware removes the raw body from the request. Best used after the request body has been parsed.

Usage
=====

[](#usage)

In the following example the [`CORS`](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) to allow everything in the `/css/` and `/js/` and by falling back to [`christoph-kluge/reactphp-http-cors-middleware`](https://github.com/christoph-kluge/reactphp-http-cors-middleware)for everything else.

**Note: This is an actual use case from [`WyriMaps.net`](https://www.wyrimaps.net) where there is an embeddable map `JS`, `CSS`, and images files served from that domain.**

```
$server = new Server([
    /** Other Middleware */
    new ContextualMiddlewareRunner(
        function (ServerRequestInterface $request) {
            if (substr($request->getUri()->getPath(), 0, 4) === '/js/') {
                return true;
            }

            if (substr($request->getUri()->getPath(), 0, 5) === '/css/') {
                return true;
            }

            return false;
        },
        [
            new WithHeadersMiddleware([
                'Access-Control-Allow-Origin' => '*',
            ]),
        ],
        [
            // Middleware from christoph-kluge/reactphp-http-cors-middleware, not shipping with this package!!!
            // (But highly reccomended!)
            new CorsMiddleware([
                'allow_origin' => [
                    'https://www.wyrimaps.net',
                ],
            ]),
        ]
    )
    /** Other Middleware */
]);
```

License
=======

[](#license)

The MIT License (MIT)

Copyright (c) 2018 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance45

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2860d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (31 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (6 commits)")[![mookman288](https://avatars.githubusercontent.com/u/2126330?v=4)](https://github.com/mookman288 "mookman288 (2 commits)")

---

Tags

hacktoberfesthttpmiddlewarephpphp7php72reactphp

### Embed Badge

![Health badge](/badges/wyrihaximus-react-http-contextual-middleware-runner/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-react-http-contextual-middleware-runner/health.svg)](https://phpackages.com/packages/wyrihaximus-react-http-contextual-middleware-runner)
```

###  Alternatives

[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

538204.9M23](/packages/league-uri-interfaces)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

184616.9k31](/packages/laudis-neo4j-php-client)[discord-php/http

Handles HTTP requests to Discord servers

25318.7k8](/packages/discord-php-http)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[clue/soap-react

Simple, async SOAP webservice client library, built on top of ReactPHP

64118.0k1](/packages/clue-soap-react)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
