JavaWebStack / JavaWebStack/web-framework

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

Đang mở
#2 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Java
Star
0
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu từ các điểm vào đăng ký HTTPServer được thể hiện trong setupServer: controller, middleware và beforeAny. Theo dõi cách thứ tự đăng ký ảnh hưởng đến việc kích hoạt middleware, sau đó xác định việc hoàn thành là khi cả hai mẫu mã đều áp dụng middleware tương đương; cân nhắc log cảnh báo được yêu cầu như một phương án thay thế nếu không thể đảm bảo tính độc lập với thứ tự.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
backend
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.