1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

expose request from transport (#2427)

This commit is contained in:
Tony Chen 2022-10-09 16:50:09 +08:00 committed by GitHub
parent 9301bfa407
commit 468630cc4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,6 +70,16 @@ func SetOperation(ctx context.Context, op string) {
}
}
// RequestFromServerContext returns request from context.
func RequestFromServerContext(ctx context.Context) (*http.Request, bool) {
if tr, ok := transport.FromServerContext(ctx); ok {
if tr, ok := tr.(*Transport); ok {
return tr.request, true
}
}
return nil, false
}
type headerCarrier http.Header
// Get returns the value associated with the passed key.