FromHTTPRequest converts an ordinary http.Request into an httpgrpc.HTTPRequest
(r *http.Request)
| 44 | |
| 45 | // FromHTTPRequest converts an ordinary http.Request into an httpgrpc.HTTPRequest |
| 46 | func FromHTTPRequest(r *http.Request) (*HTTPRequest, error) { |
| 47 | body, err := io.ReadAll(r.Body) |
| 48 | if err != nil { |
| 49 | return nil, err |
| 50 | } |
| 51 | return &HTTPRequest{ |
| 52 | Method: r.Method, |
| 53 | Url: r.RequestURI, |
| 54 | Body: body, |
| 55 | Headers: FromHeader(r.Header), |
| 56 | }, nil |
| 57 | } |
| 58 | |
| 59 | // ToHTTPRequest converts httpgrpc.HTTPRequest to http.Request. |
| 60 | func ToHTTPRequest(ctx context.Context, r *HTTPRequest) (*http.Request, error) { |