Comments (6)
A little bit of background: If it had this functionality, I would gladly use this library in Flarum in order to use PSR-15 middleware. We're currently using Zend's Stratigility, but their PSR-15-compatible version does not support PHP 7.0, which is - currently - still a requirement on our side.
from broker.
Would adding this functionality introduce new dependencies? I like the idea of it.
For whatever it's worth, the functionality is already possible by doing something like this:
$broker->when($this->matchesPath('/foo'), MyMiddleware::class);
Assuming that:
private function matchesPath(string $path): callable
{
return static function (RequestInterface $request) use ($path): bool {
return strpos($request->getUri()->getPath(), $path) === 0;
};
}
from broker.
I would implement it without external dependencies.
Stratigility additionally strips out the path prefix from the request - which is very useful because the middleware does not need to know about the prefix. So just matchesPath
is not enough.
@shadowhand Is that a "go ahead" then? 😀
from broker.
@franzliedke sure, I'd definitely consider a PR. Seems like it will be reasonable.
from broker.
Little status update:
I got path matching working. The only thing remaining is to change the request's URI object so that subsequent middleware does not have to know about the path prefix.
from broker.
Closing, see discussion on #7
from broker.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from broker.