JavaWebStack / JavaWebStack/web-framework

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

Offen
#2 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Java
Sterne
0
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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());
}
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne bei den in setupServer gezeigten HTTPServer-Registrierungseinstiegspunkten: controller, middleware und beforeAny. Verfolge, wie sich die Registrierungsreihenfolge auf die Aktivierung der Middleware auswirkt, und definiere die Fertigstellung so, dass beide Codebeispiele die Middleware gleichwertig anwenden; betrachte das angeforderte Warnprotokoll als Alternative, falls Reihenfolgeunabhängigkeit nicht umsetzbar ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.