MCPcopy
hub / github.com/grafana/dskit / FromHTTPRequest

Function FromHTTPRequest

httpgrpc/httpgrpc.go:46–57  ·  view source on GitHub ↗

FromHTTPRequest converts an ordinary http.Request into an httpgrpc.HTTPRequest

(r *http.Request)

Source from the content-addressed store, hash-verified

44
45// FromHTTPRequest converts an ordinary http.Request into an httpgrpc.HTTPRequest
46func 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.
60func ToHTTPRequest(ctx context.Context, r *HTTPRequest) (*http.Request, error) {

Callers 4

ServeHTTPMethod · 0.92
createRequestFunction · 0.92
TestOTelTracingFunction · 0.92
TestHTTPGRPCTracingFunction · 0.92

Calls 1

FromHeaderFunction · 0.85

Tested by 3

createRequestFunction · 0.74
TestOTelTracingFunction · 0.74
TestHTTPGRPCTracingFunction · 0.74