httptools

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v0.0.7

func Delete(ctx context.Context, url string) ([]byte, int, error)

func Get added in v0.0.7

func Get(ctx context.Context, url string) ([]byte, int, error)

func HandleError

func HandleError(ctx context.Context, err error, w http.ResponseWriter)

func HandleResponse

func HandleResponse(w http.ResponseWriter, b []byte, statusCode int)

func IsOkResponse

func IsOkResponse(resp *http.Response) bool

Validates that the response code is a 2xx

func MarshalFormat

func MarshalFormat(ctx context.Context, v interface{}) ([]byte, error)

func NewRequest added in v0.0.5

func NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

func Patch added in v0.0.7

func Patch(ctx context.Context, url string, requestModel interface{}) ([]byte, int, error)

Does a PUT to the specified endpoint. Returns the body bytes, an http status code (0 if no call was made)

func Post added in v0.0.5

func Post(ctx context.Context, url string, requestModel interface{}) ([]byte, int, error)

Does a POST to the specified endpoint. Returns the body bytes, an http status code (0 if no call was made)

func ProcessResponse

func ProcessResponse(ctx context.Context, v interface{}, w http.ResponseWriter, statusCode int)

func Put added in v0.0.7

func Put(ctx context.Context, url string, requestModel interface{}) ([]byte, int, error)

Does a PUT to the specified endpoint. Returns the body bytes, an http status code (0 if no call was made)

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

Jump to

Keyboard shortcuts

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