rest

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 5 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL