Skip to content

Conversation

@markstory
Copy link
Member

* Add new group features.
* Better explain how scoped middleware works.
* Add onion images. Refs #5087
@markstory markstory added this to the 3.next milestone Jul 17, 2017
@jeremyharris
Copy link
Member

Something that confused me with this image during your talk is that it looks like the response goes through the middleware stack as well.

Copy link
Member

@ravage84 ravage84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

Scoped Middleware
-----------------

Middleware can now be conditionally applied to only routes in specific URL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to only routes in specific URL scopes."
The "only" seems to be misplaced. Not an English native speaker, though.

"to routes in specific URL scopes, only."
May be? Sounds more correct to me, at least.

class Application extends BaseApplication
{
public function middleware($middlewareStack)
public function middleware($middleware)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind this renaming? I'd prefer with the "Stack" suffix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/cakephp/app/blob/master/src/Application.php#L37

We currently name the parameter $middlewareQueue in the app skeleton.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought so. Is there a reason not to change this in the app skeleton?

Copy link
Contributor

@inoas inoas Jul 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the it without or with Stack... Queue is in the "people will miss-type it" ballpark and we should IMHO change the app skeleton if possible.

Edit: But then there is \Cake\Http\MiddlewareQueue which $middleware references a copy of...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was already changed: cakephp/app#507 so why changing it again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks for pointing that out. But then it should be named middlewareQueue, as in https://github.com/cakephp/app/blob/6d9a9909fea0f06fe305d6095c1b33d3cac65e80/src/Application.php#L39. Otherwise we need to update the docs later again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed now.

$routes->registerMiddleware('cookie', new EncryptedCookieMiddleware());
$routes->registerMiddleware('auth', new AuthenticationMiddleware());
$routes->registerMiddleware('csrf', new CsrfProtectionMiddleware());
$routes->middlewareGroup('web', ['cookie', 'auth', 'csrf']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"web" seems a very general. How about "authenticated_site" or amything like that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like web, because it is not about auth here but about the context of middleware application.
On the web context you pass request/response through cookie, auth, csrf

@markstory
Copy link
Member Author

Something that confused me with this image during your talk is that it looks like the response goes through the middleware stack as well.

@jeremyharris The response does go through all the layers on the way out as well.

@jeremyharris
Copy link
Member

jeremyharris commented Jul 17, 2017

@markstory oh! Learned something new today! 🎉

Edit: d'oh, of course it does! All middleware takes the response and request in $next. Silly me.

@markstory markstory merged commit 361dfe9 into 3.next Jul 19, 2017
@markstory markstory deleted the scoped-middleware branch July 19, 2017 04:39
'Server.buildMiddleware',
function ($event, $middlewareStack) {
$middlewareStack->add(new ContactPluginMiddleware());
function ($event, $middlewareQueueStack) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... this gave me some laughs... :)

So now it is sometimes middlewareQueue and sometimes middlewareQueueStack ;)?

Personally I'd rename the core class to MiddlewareStack and alias it from middlewareQueue to be removed in 4.0. Stack is easier to type and speak.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a mistake. I will get that fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants