Skip to content

Less mess up potential when registering middleware and controllers by making the order of registration irrelevant #2

@TimothyGillespie

Description

@TimothyGillespie

Is your feature request related to a problem? Please describe.
When the controllers are registered before the middlewares the middlewares don't work or kick into action. I was confused about this and this is a potential for frustration and wasted time debugging.

Describe the solution you'd like
The order of registration becomes irrelevant.

Describe alternatives you've considered
Providing informative information via the logger on at least warning level.

Additional context

Working code sample:

    public void setupServer(HTTPServer httpServer) {
        httpServer.middleware("auth", new AuthenticationMiddleware());
        httpServer.beforeAny("/api", new AuthenticationMiddleware());
        httpServer.controller(HttpController.class, RootController.class.getPackage());
    }

Unexpetedly broken sample:

    public void setupServer(HTTPServer httpServer) {
        httpServer.controller(HttpController.class, RootController.class.getPackage());
        httpServer.middleware("auth", new AuthenticationMiddleware());
        httpServer.beforeAny("/api", new AuthenticationMiddleware());
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions