You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a couple of iterations, I came up with mdlayher/zedhook@333d2b6 for my HTTP server which accepts incoming requests via UNIX socket.
Would it make sense to incorporate a version of this in this package? Roughly:
package peercred
// A contextKey is an opaque structure used as a key for context.Context values.typecontextKeystruct{ namestring }
// ContextKey stores *Creds in a context.Context Value.varContextKey=&contextKey{"peercred"}
// ConnContext provides a hook to store *Creds for a UNIX socket client in the// context for a *http.Request. Use this function with *http.Server's ConnContext field.//// TODO: better name?funcConnContext(ctx context.Context, c net.Conn) context.Context {
// Best effort; we don't know if net.Conn is *net.UnixConn.ifcreds, err:=peercred.Get(c); err==nil {
ctx=context.WithValue(ctx, ContextKey, creds)
}
returnctx
}
After a couple of iterations, I came up with mdlayher/zedhook@333d2b6 for my HTTP server which accepts incoming requests via UNIX socket.
Would it make sense to incorporate a version of this in this package? Roughly:
Usage:
/cc @bradfitz
The text was updated successfully, but these errors were encountered: