{"id":15029524,"url":"https://github.com/wyrihaximus/reactphp-http-contextual-middleware-runner","last_synced_at":"2025-09-14T23:12:17.972Z","repository":{"id":52421206,"uuid":"139635579","full_name":"WyriHaximus/reactphp-http-contextual-middleware-runner","owner":"WyriHaximus","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-04T05:55:12.000Z","size":212,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T04:29:45.581Z","etag":null,"topics":["hacktoberfest","http","middleware","php","php7","php72","reactphp"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WyriHaximus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"WyriHaximus"}},"created_at":"2018-07-03T20:46:37.000Z","updated_at":"2020-10-04T20:04:58.000Z","dependencies_parsed_at":"2025-01-19T21:45:27.584Z","dependency_job_id":"31334bd6-d2e9-4a0d-a87e-16fd6badc58f","html_url":"https://github.com/WyriHaximus/reactphp-http-contextual-middleware-runner","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":0.5,"last_synced_commit":"3cada0eab172f06d31e0e780b768431107658642"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-http-contextual-middleware-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-http-contextual-middleware-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-http-contextual-middleware-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-http-contextual-middleware-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WyriHaximus","download_url":"https://codeload.github.com/WyriHaximus/reactphp-http-contextual-middleware-runner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WyriHaximus%2Freactphp-http-contextual-middleware-runner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259178493,"owners_count":22817386,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","http","middleware","php","php7","php72","reactphp"],"created_at":"2024-09-24T20:10:54.183Z","updated_at":"2025-06-11T01:07:06.946Z","avatar_url":"https://github.com/WyriHaximus.png","language":"PHP","funding_links":["https://github.com/sponsors/WyriHaximus"],"categories":[],"sub_categories":[],"readme":"# Run a set of react/http middleware when a context checker passes\n\n[![Build Status](https://travis-ci.com/WyriHaximus/reactphp-http-contextual-middleware-runner.svg?branch=master)](https://travis-ci.com/WyriHaximus/reactphp-http-contextual-middleware-runner)\n[![Latest Stable Version](https://poser.pugx.org/WyriHaximus/react-http-contextual-middleware-runner/v/stable.png)](https://packagist.org/packages/WyriHaximus/react-http-contextual-middleware-runner)\n[![Total Downloads](https://poser.pugx.org/WyriHaximus/react-http-contextual-middleware-runner/downloads.png)](https://packagist.org/packages/WyriHaximus/react-http-contextual-middleware-runner)\n[![Code Coverage](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-http-contextual-middleware-runner/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-http-contextual-middleware-runner/?branch=master)\n[![License](https://poser.pugx.org/WyriHaximus/react-http-contextual-middleware-runner/license.png)](https://packagist.org/packages/WyriHaximus/react-http-contextual-middleware-runner)\n[![PHP 7 ready](http://php7ready.timesplinter.ch/WyriHaximus/reactphp-http-middleware-clear-body/badge.svg)](https://travis-ci.org/WyriHaximus/reactphp-http-middleware-clear-body)\n\n# Install\n\nTo install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.\n\n```\ncomposer require wyrihaximus/react-http-contextual-middleware-runner\n```\n\nThis middleware removes the raw body from the request. Best used after the request body has been parsed.\n\n# Usage\n\nIn the following example the [`CORS`](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) to allow everything in \nthe `/css/` and `/js/` and by falling back to [`christoph-kluge/reactphp-http-cors-middleware`](https://github.com/christoph-kluge/reactphp-http-cors-middleware) \nfor everything else.\n\n**Note: This is an actual use case from [`WyriMaps.net`](https://www.wyrimaps.net) where there is an embeddable map \n`JS`, `CSS`, and images files served from that domain.**\n\n```php\n$server = new Server([\n    /** Other Middleware */\n    new ContextualMiddlewareRunner(\n        function (ServerRequestInterface $request) {\n            if (substr($request-\u003egetUri()-\u003egetPath(), 0, 4) === '/js/') {\n                return true;\n            }\n\n            if (substr($request-\u003egetUri()-\u003egetPath(), 0, 5) === '/css/') {\n                return true;\n            }\n\n            return false;\n        },\n        [\n            new WithHeadersMiddleware([\n                'Access-Control-Allow-Origin' =\u003e '*',\n            ]),\n        ],\n        [\n            // Middleware from christoph-kluge/reactphp-http-cors-middleware, not shipping with this package!!!\n            // (But highly reccomended!)\n            new CorsMiddleware([\n                'allow_origin' =\u003e [\n                    'https://www.wyrimaps.net',\n                ],\n            ]),\n        ]\n    )\n    /** Other Middleware */\n]);\n```\n\n# License\n\nThe MIT License (MIT)\n\nCopyright (c) 2018 Cees-Jan Kiewiet\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyrihaximus%2Freactphp-http-contextual-middleware-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwyrihaximus%2Freactphp-http-contextual-middleware-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwyrihaximus%2Freactphp-http-contextual-middleware-runner/lists"}