api

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 13 Imported by: 2 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 = "organization"
	LabelKeyUsername  = "username"
)
View Source
const (
	MethodAny = "ANY"
	MethodWS  = "WS"
)
View Source
const ErrorSourceUnknown = "Unknown"

Variables

This section is empty.

Functions

func StatusCode

func StatusCode(err error) int

Types

type ClientTLS

type ClientTLS struct {
	CertBundle certutil.CertBundle
	RootCAs    []*x509.Certificate
}

ClientTLS is the certificate a client presents, if any, and the CAs it verifies the server against - the system's when RootCAs is empty.

func (*ClientTLS) AsConfig

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

type Encoding added in v0.4.0

type Encoding string
const (
	EncodingDeflate Encoding = "deflate"
)

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"`
	Status  int        `json:"status,omitempty"`
	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 Middleware

type Middleware interface {
	common.Service
	// Func is called per attachment, again on every restart, so per-route state
	// lives in the closure. enabled is the most specific boolean under the
	// middleware's name (else the entry's presence); config is the most
	// specific non-boolean YAML, resolved independently, nil when absent.
	// An error fails registration; (nil, nil) declines the attachment.
	Func(enabled bool, config []byte) (func(echo.HandlerFunc) echo.HandlerFunc, error)
}

type RequestInfo

type RequestInfo struct {
	Server     string
	URI        string
	Method     string
	Path       string
	RawPath    string
	TraceID    string
	IP         string
	StartedAt  time.Time
	Permission string
	Poll       bool
}

RequestInfo is set on the request context by the server's Info middleware.

type ResponseInfo

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

type Router

type Router interface {
	common.Service
	// Config is YAML with one handler group per `---` document, all served by Handlers.
	Config() []byte
	Handlers() map[string]any // echo.HandlerFunc or WebSocketHandlerFunc
}

type ServerTLS

type ServerTLS struct {
	CertBundle certutil.CertBundle
	ClientCAs  []*x509.Certificate // empty: no client certificate is asked for
}

ServerTLS is the server's certificate and the CAs a client certificate is verified against. One is asked for, not required: a listener serves users by session as well, and the route decides who must present one.

func (*ServerTLS) AsConfig

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

type Stats

type Stats struct {
	RequestInfo
	ResponseInfo
}

Jump to

Keyboard shortcuts

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