proxy

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessControlAllowOriginHeader string = "Access-Control-Allow-Origin"
)

Variables

This section is empty.

Functions

func CORSMiddleware added in v0.2.0

func CORSMiddleware(accessControlAllowOrigin string) gin.HandlerFunc

func LogAndMetricsMiddleware

func LogAndMetricsMiddleware(metricPublisher MetricPublisher) gin.HandlerFunc

func NewInvalidRequestError

func NewInvalidRequestError(reason error) error

func RecoverMiddleware

func RecoverMiddleware(metricPublisher MetricPublisher) gin.HandlerFunc

Types

type Handler

type Handler interface {
	Health(c *gin.Context)
	ForwardRequest(c *gin.Context)
}

func NewHandler

func NewHandler(proxy *ReverseProxy, reqSigner RequestSigner, metricPublisher MetricPublisher) Handler

type InvalidRequestError

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

InvalidRequestError is raised when the contents of the request cause signing to fail.

func (*InvalidRequestError) Error

func (e *InvalidRequestError) Error() string

func (*InvalidRequestError) Unwrap

func (e *InvalidRequestError) Unwrap() error

type MetricPublisher

type MetricPublisher interface {
	IncrementTotalRequestCount(method string, path string)
	IncrementSignedRequestCount(method string, path string)
	IncrementInternalErrorCount(method string, path string)
	MeasureSigningDuration(method string, path string, duration float64)
	MeasureTotalDuration(method string, path string, duration float64)
}

type RequestSigner

type RequestSigner interface {
	SignRequest(req *http.Request) (*http.Request, error)
}

type ReverseProxy

type ReverseProxy struct {
	*httputil.ReverseProxy
	TargetHost string
}

func NewReverseProxy

func NewReverseProxy(target string) (*ReverseProxy, error)

type Server

type Server struct {
	http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg config.ServerConfig, handler Handler, metric MetricPublisher) *Server

func (*Server) Start

func (s *Server) Start()

Jump to

Keyboard shortcuts

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