httputil

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeferClose

func DeferClose(c io.Closer)

DeferClose captures and prints the error from closing (if an error occurs). This is designed to be used in a defer statement.

func DeleteBodyOK

func DeleteBodyOK(ctx context.Context, httpClient *http.Client, apiURL string) ([]byte, error)

DeleteBodyOK will DELETE and returns the body or an error if the response is not okay

func DoBodyOK

func DoBodyOK(ctx context.Context, httpClient *http.Client, apiURL, method string, reqBody io.Reader) ([]byte, error)

DoBodyOK returns the body or an error if the response is not okay(StatusCode >= 400)

func Errorf

func Errorf(status int, format string, args ...any) error

func GetBodyOK

func GetBodyOK(ctx context.Context, httpClient *http.Client, apiURL string) ([]byte, error)

GetBodyOK returns the body or an error if the response is not okay

func IsNotFound

func IsNotFound(err error) bool

func PostBodyOK

func PostBodyOK(ctx context.Context, httpClient *http.Client, apiURL string, reqBody io.Reader) ([]byte, error)

PostBodyOK will POST and returns the body or an error if the response is not okay

func PutBodyOK

func PutBodyOK(ctx context.Context, httpClient *http.Client, apiURL string, reqBody io.Reader) ([]byte, error)

PutBodyOK will PUT and returns the body or an error if the response is not okay

func ReadErrorBody

func ReadErrorBody(body io.Reader) (err error)

ReadErrorBody in the error case ready the body message. But return it as an error (or return an error from reading the body).

Types

type Error

type Error struct {
	Status  int
	Message string
}

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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