12345678910111213141516171819202122232425262728293031323334 |
- package rest
- import (
- "context"
- httppkg "git.nspix.com/golang/micro/gateway/http"
- "net/http"
- )
- func HttpRequestFromContext(ctx context.Context) *http.Request {
- if v := ctx.Value(restCtxRequest); v != nil {
- if r, ok := v.(*http.Request); ok {
- return r
- }
- }
- return nil
- }
- func HttpResponseFromContext(ctx context.Context) *http.Response {
- if v := ctx.Value(restCtxResponse); v != nil {
- if r, ok := v.(*http.Response); ok {
- return r
- }
- }
- return nil
- }
- func HttpContextFromContext(ctx context.Context) *httppkg.Context {
- if v := ctx.Value(restCtxHttpctx); v != nil {
- if r, ok := v.(*httppkg.Context); ok {
- return r
- }
- }
- return nil
- }
|