http

package
v0.0.0-...-a8f2c6d Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseTooLong = errors.New("response too long")

Functions

func DrainBody

func DrainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error)

DrainBody is from httputil.

func FlattenJSON

func FlattenJSON(b []byte) (flattenRes map[string]any, basicRes any, _ error)

func FlattenResponse

func FlattenResponse(request *http.Request, response *http.Response, maxSize int64) (flattenRes map[string]any, basicRes any, _ error)

FlattenResponse reads response body to a new map[string]any with a flat hierarchy.

func IsValidStatusCode

func IsValidStatusCode(code int) bool

func ReadResponse

func ReadResponse(responseBody io.ReadCloser, maxSize int64) ([]byte, error)

func ValidateStatusCode

func ValidateStatusCode(
	request *http.Request,
	response *http.Response,
	resErrMsgKey string,
	maxSize int64,
) error

ValidateStatusCode checks response status code and generates error if status code is not allowed.

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

type ResponseError

type ResponseError struct {
	// contains filtered or unexported fields
}

func NewResponseError

func NewResponseError(err error, statusCode int, failReason string) *ResponseError

func (*ResponseError) Error

func (e *ResponseError) Error() string

func (*ResponseError) FailReason

func (e *ResponseError) FailReason() string

func (*ResponseError) StatusCode

func (e *ResponseError) StatusCode() int

func (*ResponseError) Unwrap

func (e *ResponseError) Unwrap() error

Source Files

  • doer.go
  • response.go
  • utils.go

Jump to

Keyboard shortcuts

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