Add hlog.IDFromCtx
This commit is contained in:
parent
470da8d0bb
commit
8aa660046f
|
@ -129,7 +129,12 @@ func IDFromRequest(r *http.Request) (id xid.ID, ok bool) {
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id, ok = r.Context().Value(idKey{}).(xid.ID)
|
return IDFromCtx(r.Context())
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDFromCtx returns the unique id associated to the context if any.
|
||||||
|
func IDFromCtx(ctx context.Context) (id xid.ID, ok bool) {
|
||||||
|
id, ok = ctx.Value(idKey{}).(xid.ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue