httputils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON         = ContentType("application/json")
	ContentTypeTextPlain    = ContentType("text/plain")
	ContentTypeTextHTML     = ContentType("text/html")
	ContentTypeTextMarkdown = ContentType("text/markdown")
	ContentTypeTextXML      = ContentType("text/xml")
	ContentTypeXHTML        = ContentType("application/xhtml+xml")
)

Variables

View Source
var ErrRequestIntercepted = errors.New("docker request intercepted")

Functions

func IsMethodValid added in v0.4.0

func IsMethodValid(method string) bool

func IsStatusCodeValid added in v0.4.0

func IsStatusCodeValid(status int) bool

func IsSuccess added in v0.4.0

func IsSuccess(status int) bool

func LogDebug added in v0.4.0

func LogDebug(r *http.Request) *zerolog.Event

func LogError added in v0.4.0

func LogError(r *http.Request) *zerolog.Event

func LogInfo added in v0.4.0

func LogInfo(r *http.Request) *zerolog.Event

func LogWarn added in v0.4.0

func LogWarn(r *http.Request) *zerolog.Event

func ReadAllBody

func ReadAllBody(resp *http.Response) (b []byte, release func([]byte), err error)

ReadAllBody reads the body of the response into a buffer and returns it and a function to release the buffer.

Types

type AcceptContentType added in v0.4.0

type AcceptContentType []ContentType

func GetAccept added in v0.4.0

func GetAccept(h http.Header) AcceptContentType

func (AcceptContentType) AcceptHTML added in v0.4.0

func (act AcceptContentType) AcceptHTML() bool

func (AcceptContentType) AcceptJSON added in v0.4.0

func (act AcceptContentType) AcceptJSON() bool

func (AcceptContentType) AcceptMarkdown added in v0.4.0

func (act AcceptContentType) AcceptMarkdown() bool

func (AcceptContentType) AcceptPlainText added in v0.4.0

func (act AcceptContentType) AcceptPlainText() bool

func (AcceptContentType) IsEmpty added in v0.4.0

func (act AcceptContentType) IsEmpty() bool

type ContentType added in v0.4.0

type ContentType string

func GetContentType added in v0.4.0

func GetContentType(h http.Header) ContentType

func (ContentType) IsHTML added in v0.4.0

func (ct ContentType) IsHTML() bool

func (ContentType) IsJSON added in v0.4.0

func (ct ContentType) IsJSON() bool

func (ContentType) IsPlainText added in v0.4.0

func (ct ContentType) IsPlainText() bool

type InterceptFunc added in v0.7.0

type InterceptFunc func(resp *http.Response) (intercepted bool, err error)

type InterceptedTransport added in v0.7.0

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

InterceptedTransport wraps an http.RoundTripper to intercept Docker responses

func NewInterceptedTransport added in v0.7.0

func NewInterceptedTransport(transport http.RoundTripper, intercept InterceptFunc) *InterceptedTransport

func (*InterceptedTransport) RoundTrip added in v0.7.0

func (t *InterceptedTransport) RoundTrip(req *http.Request) (*http.Response, error)

type ModifyResponseFunc added in v0.4.0

type ModifyResponseFunc func(*http.Response) error

type ModifyResponseWriter added in v0.4.0

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

func NewModifyResponseWriter added in v0.4.0

func NewModifyResponseWriter(w http.ResponseWriter, r *http.Request, f ModifyResponseFunc) *ModifyResponseWriter

func (*ModifyResponseWriter) Flush added in v0.4.0

func (w *ModifyResponseWriter) Flush()

Flush sends any buffered data to the client.

func (*ModifyResponseWriter) Header added in v0.4.0

func (w *ModifyResponseWriter) Header() http.Header

func (*ModifyResponseWriter) Hijack added in v0.4.0

Hijack hijacks the connection.

func (*ModifyResponseWriter) Size added in v0.4.0

func (w *ModifyResponseWriter) Size() int

func (*ModifyResponseWriter) StatusCode added in v0.4.0

func (w *ModifyResponseWriter) StatusCode() int

func (*ModifyResponseWriter) Unwrap added in v0.4.0

func (*ModifyResponseWriter) Write added in v0.4.0

func (w *ModifyResponseWriter) Write(b []byte) (int, error)

func (*ModifyResponseWriter) WriteHeader added in v0.4.0

func (w *ModifyResponseWriter) WriteHeader(code int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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