Giter Site home page Giter Site logo

broker's People

Contributors

shadowhand avatar xedinunknown avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

broker's Issues

Indicate minimal PHP version

Hi!

Looking or a dispatcher that is compatible with PHP ^5.4 | ^7.0. Could not find the min required version here. I see that it was bult on PHP 7 (failing, by the way, on minimal dependencies, which can be remedied by explicitly depending on container-interop/container-interop:^1.2; see also this comment), but can't tell if will run with PHP 5.

Would it be possible to add some indication of minimal requirements?

Adding middleware by classname misleading

The documentation in the readme states:

When a container is provided middleware can be added by class name

But this is only true if the keys of middleware services are their class names. In any other case, this is not true. I found this to be very misleading, as it lead me to wonder about how middleware is resolved from the container by class name. Instead, it seems more clear to explain that the middleware will be retrieved from the container by key.

Why isn't broker a handler?

Upon reading the readme, I noticed that one way to dispatch the middleware pipe is with Broker::handle(). Given that a common use of handlers is as middleware dispatchers, shouldn't Broker implement RequestHandlerInterface istead of MiddlewareInterface? This would look great to the consuming code, as the entry point would just need to do the same thing it would do if it were not using Broker:

/* @var $handler Northwoods\Broker\Broker /*
$handler->handle($request);

Given that Broker would probably be the top-most item of the stack that processes a request, it would make more sense for it to be a handler, rather than middleware, IMO.

Proposal: Mapping path prefixes to middleware stacks

I will happily implement this and send a pull request, if you agree with the idea.

What do you think about something like this?

$broker->paths([
  '/foo' => $myMiddlewareStack,
  '/bar' => MyMiddleware::class,
  '/baz' => 'baz.middleware.stack'
]);

Array values can be middleware, or strings which would then be lazily resolved from the container, whenever a request with this prefix arrives.

This method would have to take care of stripping the path prefix from the request object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.