Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReqBody ¶ added in v0.10.0
func ReqBody[E any](client *http.Client, rq *http.Request, isError func(*http.Response) bool) ([]byte, error)
ReqBody sends an http.Request by http.Client and returns the contents of the response body.
If 'isError' is not nil and returns 'true', httphelper.Error is returned. httphelper.Error.Object of type 'E' is JSON-decoded from the response body. If response body does not contain JSON-encoded 'E', but contains a string, this string is returned in httphelper.Error.Message field.
Pass generichelper.NoType as 'E' to omit processing of httphelper.Error.Object.
func ReqJson ¶ added in v0.10.0
func ReqJson[O, E any](client *http.Client, rq *http.Request, isError func(*http.Response) bool) (*O, error)
ReqJson sends an http.Request by http.Client and returns output object of type 'O' passed JSON-encoded as the response body.
If 'isError' is not nil and returns 'true', httphelper.Error is returned. httphelper.Error.Object of type 'E' is JSON-decoded from the response body. If response body does not contain JSON-encoded 'E', but contains a string, this string is returned in httphelper.Error.Message field.
Pass generichelper.NoType as corresponding type argument to omit processing of either object.
Types ¶
This section is empty.