httputil

package
v0.0.0-...-34cbc82 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeouts = HTTPTimeouts{
	ReadTimeout:       30 * time.Second,
	ReadHeaderTimeout: 30 * time.Second,
	WriteTimeout:      30 * time.Second,
	IdleTimeout:       120 * time.Second,
}

Functions

func NewHttpServer

func NewHttpServer(handler http.Handler) *http.Server

Types

type HTTPOption

type HTTPOption func(srv *HTTPServer) error

func WithMaxHeaderBytes

func WithMaxHeaderBytes(max int) HTTPOption

func WithTimeouts

func WithTimeouts(timeouts HTTPTimeouts) HTTPOption

type HTTPServer

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

func StartHTTPServer

func StartHTTPServer(addr string, handler http.Handler, opts ...HTTPOption) (*HTTPServer, error)

func (*HTTPServer) Addr

func (s *HTTPServer) Addr() net.Addr

func (*HTTPServer) Close

func (s *HTTPServer) Close() error

func (*HTTPServer) Closed

func (s *HTTPServer) Closed() bool

func (*HTTPServer) Shutdown

func (s *HTTPServer) Shutdown(ctx context.Context) error

func (*HTTPServer) Stop

func (s *HTTPServer) Stop(ctx context.Context) error

type HTTPTimeouts

type HTTPTimeouts struct {
	ReadTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
}

type WrappedResponseWriter

type WrappedResponseWriter struct {
	StatusCode  int
	ResponseLen int
	// contains filtered or unexported fields
}

func NewWrappedResponseWriter

func NewWrappedResponseWriter(w http.ResponseWriter) *WrappedResponseWriter

func (*WrappedResponseWriter) Header

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

func (*WrappedResponseWriter) Write

func (w *WrappedResponseWriter) Write(bytes []byte) (int, error)

func (*WrappedResponseWriter) WriteHeader

func (w *WrappedResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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