Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Middlewares in route annotations #277

Open
xepozz opened this issue Jul 8, 2020 · 5 comments
Open

Middlewares in route annotations #277

xepozz opened this issue Jul 8, 2020 · 5 comments

Comments

@xepozz
Copy link
Member

xepozz commented Jul 8, 2020

I think it would be great to have this feature.

/**
 * @Middleware\IpFilter("127.0.0.1")
 * @Middleware\JsonParser()
 * @Middleware\ResponseDataFormatter("json")
 * @Middleware\Autologin()
 */
public function action()
{
    return $response
}
@samdark
Copy link
Member

samdark commented Jul 8, 2020

  1. Collecting annotations runtime is performance killer.
  2. We don't want to introduce container compiler pass since it complicates development and container itself significantly.
  3. There won't be a single place to define your routes.

@xepozz
Copy link
Member Author

xepozz commented Jul 8, 2020

Collecting annotations runtime is performance killer.

It doesn't matter for long-running applications

We don't want to introduce container compiler pass since it complicates development and container itself significantly.

I think this will be a necessary measure, otherwise you will have to give up a lot of amenities.
I suggest to find out the opinion of the developers (for example, by voting on the forum).

There won't be a single place to define your routes.

Too much developers likes annotations (hello PHP 8 attributes). Annotations/attributes is preferable way to configure routes.

@samdark
Copy link
Member

samdark commented Jul 8, 2020

It doesn't matter for long-running applications

Correct but main usage of the framework won't be long running applications.

@samdark
Copy link
Member

samdark commented Jul 12, 2020

Technically that would be

  1. General purpose annotation collector that, given a list of directories will scan for annotations.
  2. For runtime it can be router-specific annotation collector that calls addRoute(). That could be used in an event handler bound to ApplicationStartup event.
  3. For production it can be a console command that will collect routes and dump them into config/routes.php.

@samdark samdark added the type:feature New feature label Jul 12, 2020
@samdark
Copy link
Member

samdark commented Jul 12, 2020

Will wait for more requests for the feature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants