Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP middleware support #179

Closed
legionth opened this issue Apr 25, 2017 · 5 comments
Closed

HTTP middleware support #179

legionth opened this issue Apr 25, 2017 · 5 comments

Comments

@legionth
Copy link
Contributor

There is currently no standard of HTTP middleware in PHP, but I consider to use similar approach as the proposed standard of php-fig.

@clue clue added this to the v0.8.0 milestone Apr 26, 2017
@clue clue changed the title HTTP middlware support HTTP middleware support May 2, 2017
@andig
Copy link
Contributor

andig commented May 5, 2017

Could I propose to delay this post 0.8, potentially 0.9? php-pm is really anxious about getting our hand on 0.8 and anything that could cause a delay would be nice to postpone.

It's also not mentioned in the roadmap right now.

@WyriHaximus
Copy link
Member

Sounds good to me 👍

@clue
Copy link
Member

clue commented May 29, 2017

@andig I agree that this ticket should not block the request body parsers at all 👍

It's my understanding that the middleware support could easily be used to build request body parsers on top similar to this:

$app = function (function ServerRequestInterface $request) {
    return Response(200, array(), var_export($request->getParsedBody(), true));
};

$chain = new MiddlewareChain(
    new BufferMiddleware(1024 * 100), // buffer 100 KiB max
    new ParseBodyMiddleware(), // simply parse the buffered body
    $app // execute the actual request handler
);

$server = new Server($chain);

This is just a very rough draft and we will likely want to implement some API sugar on top of this. This is a very common feature request and probably not something we want every user to type out.

The nice thing about this is that this does not involve a BC break and we can also release this as part of v0.7.x in the future and subsequently add more parsers in the future.

I've prepared a number of PRs for this already and will look into this the upcoming weeks. Also, I'm really curious what @WyriHaximus will come up with 👍

@WyriHaximus
Copy link
Member

I've prepared a number of PRs for this already and will look into this the upcoming weeks. Also, I'm really curious what @WyriHaximus will come up with 👍

Looking forward to what you have come up with @clue, are you following the middleware PSR discussions in the FIG? Would be most interesting support that when it comes out.

With regards to body parsers I think the parsers them self are in pretty good shape but need some tweaking. Going to get issues with my plans and PR's implementing up starting tomorrow

@clue
Copy link
Member

clue commented Sep 8, 2017

Closed via #215 :shipit:

@clue clue closed this as completed Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants