dispatch icon indicating copy to clipboard operation
dispatch copied to clipboard

before()

Open DaanSchoukens opened this issue 10 years ago • 2 comments

Hi, quick question, what is the alternative to the before() method in the latest release?

DaanSchoukens avatar Dec 14 '14 16:12 DaanSchoukens

sorry, there's still no replacement for before() in the current version. this is being worked on, though it might not be implemented the same way as we had it before.

noodlehaus avatar Dec 21 '14 15:12 noodlehaus

Hey @noodlehaus, any update on this? getting to a point in an application where a before() method would really help authenticate a series of API endpoints I'm writing.

bmcminn avatar May 12 '16 06:05 bmcminn

Sorry I never got back to this. I am working on bringing back the functionality as apply($path, ...$handlers), like the following:

# apply auth() and loadBook() under this route
apply('/record/:id', auth(...), loadBook(...));

# auth() and loadBook() should have been executed
route('GET', '/record/:id/edit, showEditBookForm(...));

This would require a way to forward values from the middleware to the next handlers, for cases where the middleware is used for preparing the context for the final handlers. For ones that divert handling, this is not an issue.

Another approach might be to just allow multiple callables in the route() method like so:

route('GET', '/admin', auth(...), showDashboard(...));

Looking into this finally.

noodlehaus avatar Mar 29 '23 14:03 noodlehaus

Closing this. Features already in #90. Just verifying the minimum required PHP version for these (8+).

noodlehaus avatar Apr 03 '23 14:04 noodlehaus