JavaWebStack / JavaWebStack/web-framework
Less mess up potential when registering middleware and controllers by making the order of registration irrelevant
- Lenguaje dominante
- Java
- Estrellas
- 0
- Forks
- 0
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
**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());
}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza por los puntos de entrada de registro de HTTPServer mostrados en setupServer: controller, middleware y beforeAny. Traza cómo el orden de registro afecta a la activación del middleware y define la finalización de modo que ambos ejemplos de código apliquen el middleware de forma equivalente; considera el registro de advertencia solicitado como alternativa si no es viable que el orden sea independiente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100