MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / NewPostJsonRequestWithBody

Function NewPostJsonRequestWithBody

internal/test/client/client.gen.go:357–383  ·  view source on GitHub ↗

NewPostJsonRequestWithBody generates requests for PostJson with any type of body

(server string, contentType string, body io.Reader)

Source from the content-addressed store, hash-verified

355
356// NewPostJsonRequestWithBody generates requests for PostJson with any type of body
357func NewPostJsonRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
358 var err error
359
360 serverURL, err := url.Parse(server)
361 if err != nil {
362 return nil, err
363 }
364
365 operationPath := fmt.Sprintf("/with_json_body")
366 if operationPath[0] == '/' {
367 operationPath = "." + operationPath
368 }
369
370 queryURL, err := serverURL.Parse(operationPath)
371 if err != nil {
372 return nil, err
373 }
374
375 req, err := http.NewRequest(http.MethodPost, queryURL.String(), body)
376 if err != nil {
377 return nil, err
378 }
379
380 req.Header.Add("Content-Type", contentType)
381
382 return req, nil
383}
384
385// NewGetJsonRequest generates requests for GetJson
386func NewGetJsonRequest(server string) (*http.Request, error) {

Callers 2

PostJsonWithBodyMethod · 0.85
NewPostJsonRequestFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…