Skip to content

proposal: x/net/context/ctxhttp: Context-aware HTTP handlers #13115

Closed
@kyleconroy

Description

@kyleconroy

Proposal: add a context-aware handler interface that is similar to/mirrors http.Handler and http.HandlerFunc

type Handler interface {
    ServeHTTP(context.Context, http.ResponseWriter, *http.Request)
}

type HandlerFunc func(context.Context, http.ResponseWriter, *http.Request)

// ServeHTTP calls f(w, r).
func (f HandlerFunc) ServeHTTP(c context.Context, w http.ResponseWriter, r *http.Request) {
    f(c, w, r)
}

In the future, we’d also want to add a ServerMux that implements the above interface. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions