context

package
v0.7.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FieldClientMethod    = "method"
	FieldClientProto     = "proto"
	FieldClientUserAgent = "userAgent"
	FieldClientUrl       = "url"
	FieldClientAddress   = "address"
	FieldClientStatus    = "status"
	FieldClientDuration  = "duration"
)
View Source
const (
	FieldRequestId     = "requestId"
	FieldCorrelationId = "correlationId"
	FieldClient        = "client"
	FieldUpstream      = "upstream"
	FieldResult        = "result"
	FieldError         = "error"
)
View Source
const (
	FieldUpstreamAddress  = "address"
	FieldUpstreamStatus   = "status"
	FieldUpstreamDuration = "duration"
	FieldUpstreamUrl      = "url"
	FieldUpstreamMethod   = "method"
	FieldUpstreamProto    = "proto"
	FieldUpstreamSource   = "source"
	FieldUpstreamMatches  = "matches"
)

Variables

View Source
var (
	ErrNoRequestSet = errors.New("no request set")
)
View Source
var (
	NilRequestId = Id(uuid.Nil)
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Connector             server.ConnectorId
	FromOtherReverseProxy bool
	Request               *http.Request
	Response              http.ResponseWriter

	Status   int
	Started  time.Time
	Duration time.Duration
	// contains filtered or unexported fields
}

func (*Client) Address

func (this *Client) Address() (string, error)

func (*Client) ApplyToMap added in v0.3.0

func (this *Client) ApplyToMap(prefix string, to *map[string]interface{})

func (*Client) AsMap

func (this *Client) AsMap() map[string]interface{}

func (Client) Host

func (this Client) Host() string

func (*Client) Origin

func (this *Client) Origin() (*url.URL, error)

func (*Client) RequestedUrl

func (this *Client) RequestedUrl() (*url.URL, error)

type Context

type Context struct {
	Settings      *settings.Settings
	Client        Client
	Upstream      Upstream
	Id            Id
	CorrelationId Id
	Stage         Stage

	Logger log.Logger

	Rule   rules.Rule
	Result Result
	Error  error

	Properties map[string]interface{}
}

func AcquireContext

func AcquireContext(
	s *settings.Settings,
	connector server.ConnectorId,
	fromOtherReverseProxy bool,
	resp http.ResponseWriter,
	req *http.Request,
	logger log.Logger,
) (*Context, *http.Request, error)

func OfRequest added in v0.7.0

func OfRequest(req *http.Request) *Context

func (*Context) AsMap

func (this *Context) AsMap(inlineFields bool) map[string]interface{}

func (*Context) Done

func (this *Context) Done(result Result, err ...error)

func (*Context) Log

func (this *Context) Log() log.Logger

func (*Context) LogProvider added in v0.7.0

func (this *Context) LogProvider() func() log.Logger

func (*Context) MarkError

func (this *Context) MarkError(err error)

func (*Context) MarkUnavailable

func (this *Context) MarkUnavailable(err error)

func (*Context) MarkUnknown

func (this *Context) MarkUnknown()

func (*Context) MarshalJSON

func (this *Context) MarshalJSON() ([]byte, error)

func (*Context) NewGenericResponse added in v0.1.12

func (this *Context) NewGenericResponse(statusCode int, message string) *GenericResponse

func (*Context) Release

func (this *Context) Release() error

type GenericResponse added in v0.1.12

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

func (*GenericResponse) SetData added in v0.1.12

func (this *GenericResponse) SetData(data interface{}) *GenericResponse

func (*GenericResponse) SetPath added in v0.1.12

func (this *GenericResponse) SetPath(path string) *GenericResponse

func (*GenericResponse) StreamAsJson added in v0.1.12

func (this *GenericResponse) StreamAsJson()

func (GenericResponse) StreamAsXml added in v0.1.12

func (this GenericResponse) StreamAsXml()

func (*GenericResponse) StreamAsYaml added in v0.1.12

func (this *GenericResponse) StreamAsYaml()

type Id

type Id uuid.UUID

func NewCorrelationId added in v0.1.12

func NewCorrelationId(req *http.Request) (Id, error)

func NewId

func NewId(fromOtherReverseProxy bool, req *http.Request) (Id, error)

func (Id) MarshalText added in v0.7.0

func (this Id) MarshalText() ([]byte, error)

func (Id) String

func (this Id) String() string

func (*Id) UnmarshalText added in v0.7.0

func (this *Id) UnmarshalText(in []byte) error

type MetricsCollector added in v0.1.18

type MetricsCollector interface {
	CollectContext(*Context)

	CollectClientStarted(server.ConnectorId) func()
	CollectUpstreamStarted() func()
}

type RedirectResult

type RedirectResult struct {
	StatusCode int
	Target     string
}

func (RedirectResult) Name

func (this RedirectResult) Name() string

func (RedirectResult) Status

func (this RedirectResult) Status() int

func (RedirectResult) String

func (this RedirectResult) String() string

func (RedirectResult) WasResponseSendToClient

func (this RedirectResult) WasResponseSendToClient() bool

type Result

type Result interface {
	Name() string
	String() string
	Status() int
	WasResponseSendToClient() bool
}

type ResultHandler

type ResultHandler func(ctx *Context)

type SimpleResult

type SimpleResult uint8
var (
	ResultUnknown                       SimpleResult = 0
	ResultSuccess                       SimpleResult = 1
	ResultOk                            SimpleResult = 2
	ResultFailedWithUnexpectedError     SimpleResult = 3
	ResultFailedWithRuleNotFound        SimpleResult = 4
	ResultFailedWithUpstreamUnavailable SimpleResult = 5
	ResultFailedWithAccessDenied        SimpleResult = 6
	ResultFallback                      SimpleResult = 7
	ResultFailedWithUnauthorized        SimpleResult = 8
	ResultFailedWithClientGone          SimpleResult = 9
	ResultFailedWithIllegalHost         SimpleResult = 10
)

func (SimpleResult) Name

func (this SimpleResult) Name() string

func (SimpleResult) Status

func (this SimpleResult) Status() int

func (SimpleResult) String

func (this SimpleResult) String() string

func (SimpleResult) WasResponseSendToClient

func (this SimpleResult) WasResponseSendToClient() bool

type Stage

type Stage uint8
const (
	StageUnknown                Stage = 0
	StageCreated                Stage = 1
	StageEvaluateClientRequest  Stage = 2
	StagePrepareUpstreamRequest Stage = 3
	StageSendRequestToUpstream  Stage = 4
	StagePrepareClientResponse  Stage = 5
	StageSendResponseToClient   Stage = 6
	StageDone                   Stage = 7
)

func (Stage) String

func (this Stage) String() string

type Upstream

type Upstream struct {
	Response *http.Response
	Request  *http.Request
	Address  net.Addr
	Cancel   context.CancelFunc

	Status   int
	Started  time.Time
	Duration time.Duration
}

func (*Upstream) ApplyToMap added in v0.3.0

func (this *Upstream) ApplyToMap(r rules.Rule, prefix string, to *map[string]interface{})

func (*Upstream) AsMap

func (this *Upstream) AsMap(r rules.Rule) map[string]interface{}

Jump to

Keyboard shortcuts

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