http

package
v5.4.40 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package http is a generated GoMock package.

Index

Constants

View Source
const (
	// LogNothingLevel indicates nothing will be logged for incoming/outgoing HTTP traffic.
	LogNothingLevel LogLevel = "nothing"
	// LogMetadataLevel indicates that only metadata (HTTP URI, method, response code, etc) will be logged for incoming/outgoing HTTP traffic.
	LogMetadataLevel = "metadata"
	// LogMetadataAndBodyLevel indicates that metadata and full request/reply bodies will be logged for incoming/outgoing HTTP traffic.
	LogMetadataAndBodyLevel = "metadata-and-body"
)
View Source
const AdminTokenSigningKID = "admin-token-signing-key"

AdminTokenSigningKID returns the KID of the signing key used to sign the admin token.

View Source
const RootPath = "/"

RootPath is the path used for routes that don't map to a configured bind.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	// Type specifies the type of authentication required for the interface.
	Type AuthType `koanf:"type"`
	// AuthorizedKeysPath specifies the path to an authorized_keys file which specified the allowed signers for JWT tokens
	AuthorizedKeysPath string `koanf:"authorizedkeyspath"`
	// Audience specifies the expected aud value for JWT tokens. If left empty the system hostname is used.
	Audience string `koanf:"audience"`
}

AuthConfig contains the configuration for authentication for an HTTP interface.

type AuthType

type AuthType string

AuthType defines the type for authentication types constants.

const (
	// BearerTokenAuth specifies that a legacy bearer token (v1) authentication is in use
	BearerTokenAuth AuthType = "token"

	// BearerTokenAuthV2 specifies the latest version of bearer token authention
	BearerTokenAuthV2 = "token_v2"
)

type CORSConfig

type CORSConfig struct {
	// Origin specifies the AllowOrigin option. If no origins are given CORS is considered to be disabled.
	Origin []string `koanf:"origin"`
}

CORSConfig contains configuration for Cross Origin Resource Sharing.

func (CORSConfig) Enabled

func (cors CORSConfig) Enabled() bool

Enabled returns whether CORS is enabled according to this configuration.

type ClientConfig

type ClientConfig struct {
	// AllowedInternalCIDRs lists IP ranges in CIDR notation (e.g. "10.0.0.0/8") exempted from the
	// strict-mode SSRF guard, which otherwise blocks outbound requests to non-public networks. Use
	// to permit internal flows that legitimately target a private address, such as an internal
	// credential offering or an internal OAuth user flow. Leave empty to block all non-public
	// addresses.
	AllowedInternalCIDRs []string `koanf:"allowedinternalcidrs"`
	// DeniedCIDRs lists IP ranges in CIDR notation that outbound HTTP requests must never target
	// in strict mode, in addition to the built-in blocked ranges (non-public addresses and cloud
	// metadata endpoints). Use for publicly routable ranges that are internal-only in your
	// infrastructure. Denied ranges take precedence over AllowedInternalCIDRs.
	DeniedCIDRs []string `koanf:"deniedcidrs"`
}

ClientConfig contains the configuration for outbound HTTP clients.

type Config

type Config struct {
	// InterfaceConfig contains the config for the default HTTP interface.
	InterfaceConfig `koanf:"default"`
	// AltBinds contains binds for alternative HTTP interfaces. The key of the map is the first part of the path
	// of the URL (e.g. `/internal/some-api` -> `internal`), the value is the HTTP interface it must be bound to.
	AltBinds map[string]InterfaceConfig `koanf:"alt"`
	// Client contains the configuration for outbound HTTP clients.
	Client ClientConfig `koanf:"client"`
}

Config is the top-level config struct for HTTP interfaces.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for the HTTP engine.

type EchoCreator

type EchoCreator func() (EchoServer, error)

EchoCreator is a function used to create an Echo server.

type EchoServer

type EchoServer interface {
	core.EchoRouter
	Start(address string) error
	Shutdown(ctx context.Context) error
}

EchoServer implements both the EchoRouter interface and Start function to aid testing.

type Engine

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

Engine is the HTTP engine.

func New

func New(serverShutdownCb func(), signingKeyResolver cryptoEngine.KeyResolver) *Engine

New returns a new HTTP engine. The callback is called when an HTTP interface shuts down unexpectedly.

func (*Engine) Config

func (h *Engine) Config() interface{}

Config returns the configuration of the HTTP engine.

func (*Engine) Configure

func (h *Engine) Configure(serverConfig core.ServerConfig) error

Configure loads the configuration for the HTTP engine.

func (*Engine) Name

func (h *Engine) Name() string

Name returns the name of the engine.

func (Engine) Router

func (h Engine) Router() core.EchoRouter

Router returns the router of the HTTP engine, which can be used by other engines to register HTTP handlers.

func (*Engine) Shutdown

func (h *Engine) Shutdown() error

Shutdown shuts down the HTTP engine.

func (*Engine) Start

func (h *Engine) Start() error

Start starts the HTTP engine.

type InterfaceConfig

type InterfaceConfig struct {
	// Address holds the interface address the HTTP service must be bound to, in the format of `interface:port` (e.g. localhost:5555).
	Address string `koanf:"address"`
	// CORS holds the configuration for Cross Origin Resource Sharing.
	CORS CORSConfig `koanf:"cors"`
	// Auth specifies what authentication is required when accessing this interface.
	Auth AuthConfig `koanf:"auth"`
	// TLSMode specifies whether TLS is enabled for this interface, and which flavor.
	TLSMode TLSMode `koanf:"tls"`
	// Log specifies what should be logged of HTTP requests.
	Log LogLevel `koanf:"log"`
}

InterfaceConfig contains configuration for an HTTP interface, e.g. address. It will probably contain security related properties in the future (TLS configuration, user/pwd requirements).

type LogLevel

type LogLevel string

LogLevel specifies what to log for incoming/outgoing HTTP traffic.

type MockEchoServer

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

MockEchoServer is a mock of EchoServer interface.

func NewMockEchoServer

func NewMockEchoServer(ctrl *gomock.Controller) *MockEchoServer

NewMockEchoServer creates a new mock instance.

func (*MockEchoServer) Add

func (m *MockEchoServer) Add(method, path string, handler echo.HandlerFunc, middleware ...echo.MiddlewareFunc) *echo.Route

Add mocks base method.

func (*MockEchoServer) CONNECT

func (m_2 *MockEchoServer) CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

CONNECT mocks base method.

func (*MockEchoServer) DELETE

func (m_2 *MockEchoServer) DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

DELETE mocks base method.

func (*MockEchoServer) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEchoServer) GET

GET mocks base method.

func (*MockEchoServer) HEAD

func (m_2 *MockEchoServer) HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

HEAD mocks base method.

func (*MockEchoServer) OPTIONS

func (m_2 *MockEchoServer) OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

OPTIONS mocks base method.

func (*MockEchoServer) PATCH

func (m_2 *MockEchoServer) PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

PATCH mocks base method.

func (*MockEchoServer) POST

func (m_2 *MockEchoServer) POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

POST mocks base method.

func (*MockEchoServer) PUT

PUT mocks base method.

func (*MockEchoServer) Shutdown

func (m *MockEchoServer) Shutdown(ctx context.Context) error

Shutdown mocks base method.

func (*MockEchoServer) Start

func (m *MockEchoServer) Start(address string) error

Start mocks base method.

func (*MockEchoServer) TRACE

func (m_2 *MockEchoServer) TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

TRACE mocks base method.

func (*MockEchoServer) Use

func (m *MockEchoServer) Use(middleware ...echo.MiddlewareFunc)

Use mocks base method.

type MockEchoServerMockRecorder

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

MockEchoServerMockRecorder is the mock recorder for MockEchoServer.

func (*MockEchoServerMockRecorder) Add

func (mr *MockEchoServerMockRecorder) Add(method, path, handler interface{}, middleware ...interface{}) *gomock.Call

Add indicates an expected call of Add.

func (*MockEchoServerMockRecorder) CONNECT

func (mr *MockEchoServerMockRecorder) CONNECT(path, h interface{}, m ...interface{}) *gomock.Call

CONNECT indicates an expected call of CONNECT.

func (*MockEchoServerMockRecorder) DELETE

func (mr *MockEchoServerMockRecorder) DELETE(path, h interface{}, m ...interface{}) *gomock.Call

DELETE indicates an expected call of DELETE.

func (*MockEchoServerMockRecorder) GET

func (mr *MockEchoServerMockRecorder) GET(path, h interface{}, m ...interface{}) *gomock.Call

GET indicates an expected call of GET.

func (*MockEchoServerMockRecorder) HEAD

func (mr *MockEchoServerMockRecorder) HEAD(path, h interface{}, m ...interface{}) *gomock.Call

HEAD indicates an expected call of HEAD.

func (*MockEchoServerMockRecorder) OPTIONS

func (mr *MockEchoServerMockRecorder) OPTIONS(path, h interface{}, m ...interface{}) *gomock.Call

OPTIONS indicates an expected call of OPTIONS.

func (*MockEchoServerMockRecorder) PATCH

func (mr *MockEchoServerMockRecorder) PATCH(path, h interface{}, m ...interface{}) *gomock.Call

PATCH indicates an expected call of PATCH.

func (*MockEchoServerMockRecorder) POST

func (mr *MockEchoServerMockRecorder) POST(path, h interface{}, m ...interface{}) *gomock.Call

POST indicates an expected call of POST.

func (*MockEchoServerMockRecorder) PUT

func (mr *MockEchoServerMockRecorder) PUT(path, h interface{}, m ...interface{}) *gomock.Call

PUT indicates an expected call of PUT.

func (*MockEchoServerMockRecorder) Shutdown

func (mr *MockEchoServerMockRecorder) Shutdown(ctx interface{}) *gomock.Call

Shutdown indicates an expected call of Shutdown.

func (*MockEchoServerMockRecorder) Start

func (mr *MockEchoServerMockRecorder) Start(address interface{}) *gomock.Call

Start indicates an expected call of Start.

func (*MockEchoServerMockRecorder) TRACE

func (mr *MockEchoServerMockRecorder) TRACE(path, h interface{}, m ...interface{}) *gomock.Call

TRACE indicates an expected call of TRACE.

func (*MockEchoServerMockRecorder) Use

func (mr *MockEchoServerMockRecorder) Use(middleware ...interface{}) *gomock.Call

Use indicates an expected call of Use.

type MultiEcho

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

MultiEcho allows to bind specific URLs to specific HTTP interfaces

func NewMultiEcho

func NewMultiEcho() *MultiEcho

NewMultiEcho creates a new MultiEcho which uses the given function to create core.EchoServers. If a route is registered for an unknown path is bound to the given defaultInterface.

func (*MultiEcho) Add

func (c *MultiEcho) Add(method, path string, handler echo.HandlerFunc, middleware ...echo.MiddlewareFunc) *echo.Route

Add calls the add function.

func (*MultiEcho) Bind

func (c *MultiEcho) Bind(path string, address string, creatorFn func() (EchoServer, error)) error

Bind binds the given path (first part of the URL) to the given HTTP interface. Calling Bind for the same path twice results in an error being returned. If address wasn't used for another bind and thus leads to creating a new Echo server, it returns true. If an existing Echo server is returned, it returns false.

func (*MultiEcho) CONNECT

func (c *MultiEcho) CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

CONNECT registers a new CONNECT route for the given path with optional middleware.

func (*MultiEcho) DELETE

func (c *MultiEcho) DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

DELETE registers a new DELETE route for the given path with optional middleware.

func (*MultiEcho) GET

func (c *MultiEcho) GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

GET registers a new GET route for the given path with optional middleware.

func (*MultiEcho) HEAD

func (c *MultiEcho) HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

HEAD registers a new HEAD route for the given path with optional middleware.

func (*MultiEcho) OPTIONS

func (c *MultiEcho) OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

OPTIONS registers a new OPTIONS route for the given path with optional middleware.

func (*MultiEcho) PATCH

func (c *MultiEcho) PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

PATCH registers a new PATCH route for the given path with optional middleware.

func (*MultiEcho) POST

func (c *MultiEcho) POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

POST registers a new POST route for the given path with optional middleware.

func (*MultiEcho) PUT

func (c *MultiEcho) PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

PUT registers a new PUT route for the given path with optional middleware.

func (MultiEcho) Shutdown

func (c MultiEcho) Shutdown(ctx context.Context) error

Shutdown stops all Echo servers.

func (MultiEcho) Start

func (c MultiEcho) Start() error

Start starts all Echo servers.

func (*MultiEcho) TRACE

func (c *MultiEcho) TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route

TRACE registers a new TRACE route for the given path with optional middleware.

func (MultiEcho) Use

func (c MultiEcho) Use(middleware ...echo.MiddlewareFunc)

Use applies the given middleware function to all Echo servers.

type TLSMode

type TLSMode string

TLSMode defines the values for TLS modes

const (
	// TLSDisabledMode specifies that TLS is not enabled for this interface.
	TLSDisabledMode TLSMode = "disabled"
	// TLSServerCertMode specifies that TLS is enabled for this interface, but no client certificate is required.
	TLSServerCertMode TLSMode = "server"
	// TLServerClientCertMode specifies that TLS is enabled for this interface, and that it will require a client certificate.
	TLServerClientCertMode TLSMode = "server-client"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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