How can I tell if net/http's ResponseWriter.Write() has been called?

前端 未结 2 724
无人及你
无人及你 2021-01-21 06:35

Suppose I have a chain of net/http Handlers, and an early one responds with an HTTP error (http.StatusInternalServerError, for instance). How can I detect this in

2条回答
  •  离开以前
    2021-01-21 07:02

    First: a lighter-weight solution may exist.

    However, if you cannot find one, consider using x/net/context to allow you to implement timeouts, deadlines, and of course, early termination of middleware chains.

提交回复
热议问题