api

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKeyRequestInfo  = common.ContextKeyAPIRequestInfo
	ContextKeyResponseInfo = common.ContextKeyAPIResponseInfo
	ContextKeyError        = common.ContextKeyAPIError
	ContextKeyCredential   = common.ContextKeyCredential
	ContextKeySession      = common.ContextKeySession
	ContextKeyTrace        = common.ContextKeyTrace
	ContextKeyDB           = common.ContextKeyDB
	ContextKeyLogger       = common.ContextKeyLogger

	CookiesKeySession = "JSESSIONID"

	HeaderKeyTrace        = "X-TRACE-ID"
	HeaderKeyFile         = "X-FILE-ID"
	HeaderKeyJob          = "X-JOB-ID"
	HeaderKeySession      = "X-SESSION-ID"
	HeaderKeyAPIToken     = "X-API-KEY"
	HeaderKeyAgentID      = "X-AGENT-ID"
	HeaderKeyClientCert   = "X-Ssl-Certificate"        // from nginx proxy_set_header $ssl_client_escaped_cert
	HeaderKeyClientVerify = "X-Ssl-Certificate-Verify" // from nginx proxy_set_header $ssl_client_verify

	QueryParamSession = "sid"
	QueryParamJob     = "job"

	LabelKeySession   = "session"
	LabelKeyNamespace = "namespace"
	LabelKeyUsername  = "username"
)
View Source
const DefaultAPIPrefix = "/"
View Source
const ErrorSourceUnknown = "Unknown"

Variables

This section is empty.

Functions

func HandlerKey

func HandlerKey(g *HandlerGroup, h *Handler) string

func StatusCode

func StatusCode(err error) int

Types

type ClientTLS

type ClientTLS struct {
	CertBundle certutil.CertBundle
	AuthType   tls.ClientAuthType
}

func (*ClientTLS) AsConfig

func (ct *ClientTLS) AsConfig() *tls.Config

type Endpoint

type Endpoint struct {
	Protocol string
	Host     string
	Port     uint
	Path     string
}

func NewEndpoint

func NewEndpoint(address string) *Endpoint

func (*Endpoint) Address

func (e *Endpoint) Address() string

func (*Endpoint) String

func (e *Endpoint) String() string

type ErrorBody

type ErrorBody struct {
	Origin  error      `json:"-"`                // keep the original error to trace the stack
	Source  string     `json:"source,omitempty"` // source
	Status  int        `json:"status,omitempty"` // http status code
	Code    string     `json:"code,omitempty"`   // customized error code
	Kind    string     `json:"kind,omitempty"`   // error category
	Message string     `json:"message,omitempty"`
	Details labels.Set `json:"details,omitempty"`
}

func WrapError

func WrapError(err error, c echo.Context) *ErrorBody

func (*ErrorBody) Error

func (e *ErrorBody) Error() string

func (*ErrorBody) Format

func (e *ErrorBody) Format(f fmt.State, c rune)

type Handler

type Handler struct {
	Method      string          `json:"method"`
	Path        string          `json:"path"`
	Middlewares []string        `json:"middlewares"`
	Permission  string          `json:"permission"`
	Poll        bool            `json:"poll"`
	Throttle    *ThrottleConfig `json:"throttle,omitempty"`
	Func        string          `json:"func"`
}

type HandlerGroup

type HandlerGroup struct {
	Server      string     `json:"server"` // default: http
	Prefix      string     `json:"prefix"` // default: /
	Handlers    []*Handler `json:"handlers"`
	Middlewares []string   `json:"middlewares"`
}

type Middleware

type Middleware interface {
	common.Service
	Func(echo.HandlerFunc) echo.HandlerFunc
}

type RequestInfo

type RequestInfo struct {
	Server       string
	URI          string
	Method       string
	Path         string
	RawPath      string
	TraceID      string
	IP           string
	StartedAt    time.Time
	Handler      *Handler
	HandlerGroup *HandlerGroup
}

func (*RequestInfo) Key

func (s *RequestInfo) Key(prefix string) string

type ResponseInfo

type ResponseInfo struct {
	Status  int
	Took    time.Duration
	Size    uint64
	TraceID string
	Error   *ErrorBody
}

type Router

type Router interface {
	common.Service
	Config() []byte
	Handlers() map[string]echo.HandlerFunc
}

type ServerTLS

type ServerTLS struct {
	CertBundle  certutil.CertBundle
	AuthEnabled bool
}

func (*ServerTLS) AsConfig

func (st *ServerTLS) AsConfig() *tls.Config

type Stats

type Stats struct {
	RequestInfo
	ResponseInfo
}

type ThrottleConfig

type ThrottleConfig struct {
	RPS       rate.Limit `json:"rps"`
	BurstSize int        `json:"burst_size"`
}

Jump to

Keyboard shortcuts

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