Skip to content

proposal: net/http: add context cancelation reason for server handlers #64465

@hummerd

Description

@hummerd

Proposal Details

While serving HTTP request we have req.Context() that can be propagated down the pipe. This context can be canceled either by standard library - by http.Server itself in case of communication issues or by http.TimeoutHandler. But also it can be canceled by user code.
It would be nice to have ability to clarify the reason why context was canceled (in case it was canceled by standard library). Logged reason will make you 100% sure and should make investigation of such context cancellation errors easier.

I'm ready to make a PR in case this proposal is considered useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions