http

package
v0.0.0-...-2735486 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingAcceptHeader   = "Accept-Encoding"
	EncodingResponseHeader = "Content-Encoding"
)
View Source
const (
	ContentLengthHeader = "Content-Length"
)
View Source
const ContentTypeHeader = "Content-Type"

Variables

This section is empty.

Functions

func DefaultHTTPServerSettings

func DefaultHTTPServerSettings(in *http.Server, _ context.Context) error

func Download

func Download(ctx context.Context, client *http.Client, format string, args ...interface{}) ([]byte, error)

func InitConfiguration

func InitConfiguration(cmd *cobra.Command) error

func Insecure

func Insecure(in *tls.Config)

func NewError

func NewError(code int, format string, args ...any) error

func NewSimpleJSONResponse

func NewSimpleJSONResponse(obj interface{}) (http.Handler, error)

NewSimpleJSONResponse returns handler which server static json on GET request

func NewWriter

func NewWriter(w http.ResponseWriter, stream io.Writer) http.ResponseWriter

func RoundTripper

func RoundTripper(mods ...mod.Mod[*http.Transport]) http.RoundTripper

func RoundTripperWithShortTransport

func RoundTripperWithShortTransport(mods ...mod.Mod[*http.Transport]) http.RoundTripper

func Transport

func Transport(mods ...mod.Mod[*http.Transport]) http.RoundTripper

func WithBuffer

func WithBuffer(maxSize int, in http.HandlerFunc) http.HandlerFunc

func WithContentType

func WithContentType(content string, in http.HandlerFunc) http.HandlerFunc

func WithEncoding

func WithEncoding(in http.HandlerFunc) http.HandlerFunc

func WithGZipEncoding

func WithGZipEncoding(in http.HandlerFunc) http.HandlerFunc

func WithIdentityEncoding

func WithIdentityEncoding(in http.HandlerFunc) http.HandlerFunc

func WithNoContent

func WithNoContent(in http.HandlerFunc) http.HandlerFunc

func WithRootCA

func WithRootCA(ca *x509.CertPool) mod.Mod[*tls.Config]

func WithServeMux

func WithServeMux(mods ...util.Mod[http.ServeMux]) util.ModEP1[http.Server, context.Context]

func WithTLSConfigFetcher

func WithTLSConfigFetcher(fetcher util.TLSConfigFetcher) util.ModEP1[http.Server, context.Context]

func WithTLSConfigFetcherGen

func WithTLSConfigFetcherGen(gen func() util.TLSConfigFetcher) util.ModEP1[http.Server, context.Context]

func WithTextContentType

func WithTextContentType(in http.HandlerFunc) http.HandlerFunc

func WithTransportTLS

func WithTransportTLS(mods ...mod.Mod[*tls.Config]) mod.Mod[*http.Transport]

func WrapError

func WrapError(code int, err error) error

Types

type Buffer

type Buffer interface {
	io.Writer

	Bytes() []byte
	Truncated() bool
}

func NewBuffer

func NewBuffer(maxSize int, upstream io.Writer) Buffer

type Error

type Error struct {
	Code    int
	Message string
}

func IsError

func IsError(err error) (Error, bool)

func (Error) Error

func (e Error) Error() string

func (Error) JSON

func (e Error) JSON() []byte

type Headers

type Headers map[string]float64

func ParseHeaders

func ParseHeaders(in ...string) Headers

func (Headers) Accept

func (h Headers) Accept(headers ...string) string

type Server

type Server interface {
	AsyncAddr(ctx context.Context, addr string) func() error
	Async(ctx context.Context, ln net.Listener) func() error

	StartAddr(ctx context.Context, addr string) error
	Start(ctx context.Context, ln net.Listener) error
}

func NewServer

func NewServer(ctx context.Context, mods ...util.ModEP1[http.Server, context.Context]) (Server, error)

Jump to

Keyboard shortcuts

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