ToHTTPRequest converts httpgrpc.HTTPRequest to http.Request.
(ctx context.Context, r *HTTPRequest)
| 58 | |
| 59 | // ToHTTPRequest converts httpgrpc.HTTPRequest to http.Request. |
| 60 | func ToHTTPRequest(ctx context.Context, r *HTTPRequest) (*http.Request, error) { |
| 61 | req, err := http.NewRequest(r.Method, r.Url, nopCloser{Buffer: bytes.NewBuffer(r.Body)}) |
| 62 | if err != nil { |
| 63 | return nil, err |
| 64 | } |
| 65 | ToHeader(r.Headers, req.Header) |
| 66 | req = req.WithContext(ctx) |
| 67 | req.RequestURI = r.Url |
| 68 | req.ContentLength = int64(len(r.Body)) |
| 69 | return req, nil |
| 70 | } |
| 71 | |
| 72 | // WriteResponse converts an httpgrpc response to an HTTP one |
| 73 | func WriteResponse(w http.ResponseWriter, resp *HTTPResponse) error { |
no test coverage detected