http

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 26 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)

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.AuthenticationClientConfig
}

type Config

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

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 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

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
	// 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)
}

Directories

Path Synopsis
authz
ip

Jump to

Keyboard shortcuts

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