coder / coder/websocket

Allow customize how HTTP errors are rendered when `websocket.Accept` fails to upgrade

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

Mô tả

IDEA: Might be as simple as a new `HttpErrorRenderer` (or `OnError`, etc.) option added to `websocket.AcceptOptions`. When unspecified, default to a fn that implements current rendering behavior. It would take at minimum a `ctx`, the `err` and the http `status` code.

Nice addition: the full set of `errors.New("..")` would be exposed to user so that one can use `errors.Is` to get more granularity than provided http statuses.

We need this feature in order to produce (a standardized JSON error response format) when an error occurs in order to match the rest of our API which produces this error response format for all of its endpoints. Current hard-coded behavior prevents us to comply with our policy when WS upgrade fails in this library. Our user thus can't systematically assume this nice JSON format and must workaround this limitation...

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

Đánh giá

Issue này chưa được đánh giá.

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.