Help us shape the future of Go! Take the 2026 Go Developer Survey

httpx

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyReaderHandler

func BodyReaderHandler(next http.Handler, maxMemory int64) http.Handler

BodyReaderHandler reads body so it will appear in request log.

func NotifyHandler

func NotifyHandler(notify NotifyFunc, next http.Handler) http.Handler

Types

type Meta

type Meta struct {
	Request  Request  `json:"request"`
	Response Response `json:"response"`
}

Meta contains HTTP-specific event metadata.

type NotifyFunc

type NotifyFunc func(
	ctx context.Context,
	remoteAddr net.Addr,
	receivedAt *time.Time,
	secure bool,
	data [][]byte,
	match []byte,
	meta *Meta,
)

type Option

type Option func(*options)

func WithListenerWrapper added in v1.26.0

func WithListenerWrapper(f func(net.Listener) net.Listener) Option

WithListenerWrapper wraps the listener, e.g. to reject connections before the TLS handshake.

func WithNotifyStarted added in v1.26.0

func WithNotifyStarted(f func()) Option

WithNotifyStarted sets a function called once the server is listening.

func WithTLSConfig added in v1.26.0

func WithTLSConfig(cfg *tls.Config) Option

WithTLSConfig makes the server accept TLS connections.

type Request

type Request struct {
	Method  string      `json:"method"`
	Proto   string      `json:"proto"`
	URL     string      `json:"url"`
	Host    string      `json:"host"`
	Headers http.Header `json:"headers"`
	Body    string      `json:"body"`
}

Request represents HTTP request metadata for events.

type Response

type Response struct {
	Status  int         `json:"status"`
	Headers http.Header `json:"headers"`
	Body    string      `json:"body"`
}

Response represents HTTP response metadata for events.

type Server

type Server interface {
	ListenAndServe() error
}

func New

func New(addr string, h http.Handler, opts ...Option) Server

Jump to

Keyboard shortcuts

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