http

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMapToHTTPHeader

func AddMapToHTTPHeader(baseHeaders http.Header, headerMap map[string]string) http.Header

AddMapToHTTPHeader adds a map[string]string to an existing http.Header

func CreateHTTPHeaderFromMap

func CreateHTTPHeaderFromMap(headerMap map[string]string) http.Header

CreateHTTPHeaderFromMap creates a new http.Header from a map[string]string

func NewPersistentCookieStore

func NewPersistentCookieStore(config CookieConfig) (*sessions.CookieStore, error)

func NewSessionCookieStore

func NewSessionCookieStore(config CookieConfig) (*sessions.CookieStore, error)

func StandardLogger added in v0.36.1

func StandardLogger(r *http.Request, status, size int, duration time.Duration) *zerolog.Logger

Types

type Client

type Client struct {
	Config *ClientConfig
}

func NewClient

func NewClient(config *ClientConfig) *Client

func NewDefaultClient

func NewDefaultClient() *Client

func (*Client) Request

func (c *Client) Request(req *http.Request) (*http.Response, error)

func (*Client) ResolveRelativeRequestPath

func (c *Client) ResolveRelativeRequestPath(requestPath string) (*url.URL, error)

type ClientConfig

type ClientConfig struct {
	BaseURL    *url.URL
	Client     *http.Client
	UserAgent  string
	AuthConfig auth.ClientConfig
}

type Config

type Config struct {
	ListenAddress           string
	EnablePrometheusMetrics bool
	EnableDebug             bool
	EnableStatus            bool
	EnableProxyProtocol     bool
	TLSConfig               *tls.Config
	AuthConfig              auth.ServerConfig
}

Config ...

type CookieConfig

type CookieConfig struct {
	Base64AuthenticationKey string `mapstructure:"base64-authentication-key"`
	Base64EncryptionKey     string `mapstructure:"base64-encryption-key"`
	MaxAge                  int    `mapstructure:"max-age"`
	Domain                  string `mapstructure:"domain"`
}

type DefaultResource

type DefaultResource interface {
	RegisterRoutes(*mux.Router)
}

type EnforceTLSHandler added in v0.37.0

type EnforceTLSHandler struct {
	EnforceTLS bool
}

func (*EnforceTLSHandler) Wrap added in v0.37.0

func (h *EnforceTLSHandler) Wrap(handler http.Handler) http.Handler

type HandlerWrapper

type HandlerWrapper func(next http.Handler) http.Handler

func DefaultCombinedLogHandler

func DefaultCombinedLogHandler(logWriter io.Writer) HandlerWrapper

func ZerologStructuredLogHandler

func ZerologStructuredLogHandler(logger zerolog.Logger) HandlerWrapper

func ZerologStructuredLogHandlerWithFormatter added in v0.36.1

func ZerologStructuredLogHandlerWithFormatter(logger zerolog.Logger, formatter StructuredLoggerFormatter) HandlerWrapper

type MetricSet

type MetricSet struct {
	RequestCounter  *prometheus.CounterVec
	RequestDuration *prometheus.HistogramVec
	RequestSize     *prometheus.HistogramVec
	ResponseSize    *prometheus.HistogramVec
	InFlightGauge   prometheus.Gauge
}

func NewMetricSet

func NewMetricSet(r *prometheus.Registry) *MetricSet

func (*MetricSet) Middleware

func (m *MetricSet) Middleware(next http.Handler) http.Handler

Middleware - to make it a middleware for mux probably a better way. TODO: need to extract this from this struct to remove the coupling with mux

func (*MetricSet) Register

func (m *MetricSet) Register(r prometheus.Registerer)

type PathResource

type PathResource interface {
	RegisterRoutesWithPrefix(*mux.Router, string)
}

type Resource

type Resource interface{}

type RootResource

type RootResource interface {
	//Resource
	Index() http.HandlerFunc
}

type Server

type Server struct {
	Config        Config
	ListenAddress string
	Router        *mux.Router

	ResourceMap map[string]Resource

	ListenAddr net.Addr
	LogHandler HandlerWrapper

	Authenticator *auth.Handler
	// contains filtered or unexported fields
}

Server ...

func NewServer

func NewServer(config Config, logWriter io.Writer) *Server

NewServer ...

func NewServerWithLogger

func NewServerWithLogger(config Config, logger zerolog.Logger) *Server

func (*Server) AddHandler

func (s *Server) AddHandler(path string, handler http.Handler)

func (*Server) AddHandlerFunc

func (s *Server) AddHandlerFunc(path string, handler http.HandlerFunc)

func (*Server) AddResource

func (s *Server) AddResource(pathPrefix string, r Resource)

AddResource ...

func (*Server) AddRootResource

func (s *Server) AddRootResource(r RootResource)

func (*Server) AddStatusStaticMetadataItem

func (s *Server) AddStatusStaticMetadataItem(key string, value any)

func (*Server) ConfigurePrometheusRegistry

func (s *Server) ConfigurePrometheusRegistry(r prometheus.Registerer)

func (*Server) ConfigureTelemetryInstrument

func (s *Server) ConfigureTelemetryInstrument(i middleware.Instrument)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) ListenAndServeTLS

func (s *Server) ListenAndServeTLS(tlsConfig *tls.Config) error

ListenAndServeTLS ... tlsConfig will override any prior configuration in s.Config

func (*Server) RegisterOnShutdown

func (s *Server) RegisterOnShutdown(f func())

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

func (*Server) ServeTLS

func (s *Server) ServeTLS(ln net.Listener) error

func (*Server) Shutdown

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

type StatusResource

type StatusResource interface {
	Status() (interface{}, error)
}

type StructuredLoggerFormatter added in v0.36.1

type StructuredLoggerFormatter func(r *http.Request, status, size int, duration time.Duration) *zerolog.Logger

Directories

Path Synopsis
authz
ip

Jump to

Keyboard shortcuts

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