access

package
v0.0.0-...-a3b39dc Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: BSD-3-Clause Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const (
	InternalTraffic = "internal"
	EgressTraffic   = "egress"
	IngressTraffic  = "ingress"

	XRequestId      = "x-request-id"
	XRelatesTo      = "x-relates-to"
	ContentEncoding = "Content-Encoding"
	LocationHeader  = "Location"

	Primary             = "primary"
	Secondary           = "secondary"
	ControllerTimeout   = "TO" // Controller struct code
	ControllerRateLimit = "RL" // Controller struct code
	RoutingFailover     = "FO" // Routing struct code
	RoutingRedirect     = "RD" // Routing struct code
)

Variables

This section is empty.

Functions

func BuildRequest

func BuildRequest(r any) *http.Request

func BuildResponse

func BuildResponse(r any) *http.Response

func Conditional

func Conditional(primary, secondary string) string

func CreateTo

func CreateTo(req *http.Request) string

func DefaultFormat

func DefaultFormat(o core.Origin, traffic string, start time.Time, duration time.Duration, req any, resp any, routing Routing, controller Controller) string

func Encoding

func Encoding(resp *http.Response) string

func JsonString

func JsonString(value string) string

JsonString - Json format a string value

func Log

func Log(traffic string, start time.Time, duration time.Duration, req any, resp any, routing Routing, controller Controller)

Log - access logging. Header.Get(XRequestId)), Header.Get(XRelatesTo)), Header.Get(LocationHeader)

func Milliseconds

func Milliseconds(duration time.Duration) int

Milliseconds - convert time.Duration to milliseconds

func SetLogFn

func SetLogFn(fn LogFn)

SetLogFn - override logging

func SetOrigin

func SetOrigin(o core.Origin)

SetOrigin - initialize the origin

Types

type Controller

type Controller struct {
	Timeout   time.Duration
	RateLimit float64
	RateBurst int
	Code      string
}

Controller - controller attributes

func NilController

func NilController() Controller

NilController - used when Controller is not applicable

type LogFn

type LogFn func(o core.Origin, traffic string, start time.Time, duration time.Duration, req any, resp any, routing Routing, controller Controller)

LogFn - log function

type Request

type Request interface {
	Url() string
	Header() http.Header
	Method() string
	Protocol() string
}

Request - request attributes interface for non HTTP traffic

type RequestImpl

type RequestImpl struct {
	Url      string
	Header   http.Header
	Method   string
	Protocol string
}

RequestImpl - non HTTP request attributes

type Routing

type Routing struct {
	From    string // Domain
	Route   string
	To      string // Primary, secondary
	Percent int
	Code    string
}

Routing - routing attributes

func NilRouting

func NilRouting() Routing

NilRouting - used when Routing is not applicable

Jump to

Keyboard shortcuts

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