NewPostJsonRequestWithBody generates requests for PostJson with any type of body
(server string, contentType string, body io.Reader)
| 355 | |
| 356 | // NewPostJsonRequestWithBody generates requests for PostJson with any type of body |
| 357 | func 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 |
| 386 | func NewGetJsonRequest(server string) (*http.Request, error) { |
no test coverage detected
searching dependent graphs…