JavaWebStack / JavaWebStack/web-framework

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

Aperta
#2 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Java
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia dai punti di ingresso della registrazione di HTTPServer mostrati in setupServer: controller, middleware e beforeAny. Traccia il modo in cui l’ordine di registrazione influisce sull’attivazione del middleware, quindi definisci il completamento in modo che entrambi gli esempi di codice applichino il middleware in modo equivalente; considera il log di avviso richiesto come alternativa se l’indipendenza dall’ordine non è realizzabile.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.