http

package
v6.2.13 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 HealthPath = "/health"

HealthPath is the path used for the health endpoint.

View Source
const InternalPath = "/internal"

InternalPath is the path used for internal endpoints.

View Source
const MetricsPath = "/metrics"

MetricsPath is the path used for the metrics endpoint.

View Source
const RootPath = "/"

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

View Source
const StatusPath = "/status"

StatusPath is the path used for the status endpoint.

Variables

This section is empty.

Functions

func AddQueryParams

func AddQueryParams(u url.URL, params map[string]string) url.URL

AddQueryParams adds the given params to the given url as query params

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 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 {
	// Log specifies what should be logged of HTTP requests.
	Log      LogLevel       `koanf:"log"`
	Public   PublicConfig   `koanf:"public"`
	Internal InternalConfig `koanf:"internal"`
	Client   ClientConfig   `koanf:"client"`
	// ResponseCacheSize is the maximum number of bytes cached by HTTP clients.
	ResponseCacheSize  int    `koanf:"cache.maxbytes"`
	ClientIPHeaderName string `koanf:"clientipheader"`
}

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 InternalConfig

type InternalConfig 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"`
	// Auth specifies what authentication is required when accessing this interface.
	Auth AuthConfig `koanf:"auth"`
}

InternalConfig contains the configuration for internal HTTP endpoints.

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 any, middleware ...any) *gomock.Call

Add indicates an expected call of Add.

func (*MockEchoServerMockRecorder) CONNECT

func (mr *MockEchoServerMockRecorder) CONNECT(path, h any, m ...any) *gomock.Call

CONNECT indicates an expected call of CONNECT.

func (*MockEchoServerMockRecorder) DELETE

func (mr *MockEchoServerMockRecorder) DELETE(path, h any, m ...any) *gomock.Call

DELETE indicates an expected call of DELETE.

func (*MockEchoServerMockRecorder) GET

func (mr *MockEchoServerMockRecorder) GET(path, h any, m ...any) *gomock.Call

GET indicates an expected call of GET.

func (*MockEchoServerMockRecorder) HEAD

func (mr *MockEchoServerMockRecorder) HEAD(path, h any, m ...any) *gomock.Call

HEAD indicates an expected call of HEAD.

func (*MockEchoServerMockRecorder) OPTIONS

func (mr *MockEchoServerMockRecorder) OPTIONS(path, h any, m ...any) *gomock.Call

OPTIONS indicates an expected call of OPTIONS.

func (*MockEchoServerMockRecorder) PATCH

func (mr *MockEchoServerMockRecorder) PATCH(path, h any, m ...any) *gomock.Call

PATCH indicates an expected call of PATCH.

func (*MockEchoServerMockRecorder) POST

func (mr *MockEchoServerMockRecorder) POST(path, h any, m ...any) *gomock.Call

POST indicates an expected call of POST.

func (*MockEchoServerMockRecorder) PUT

func (mr *MockEchoServerMockRecorder) PUT(path, h any, m ...any) *gomock.Call

PUT indicates an expected call of PUT.

func (*MockEchoServerMockRecorder) Shutdown

func (mr *MockEchoServerMockRecorder) Shutdown(ctx any) *gomock.Call

Shutdown indicates an expected call of Shutdown.

func (*MockEchoServerMockRecorder) Start

func (mr *MockEchoServerMockRecorder) Start(address any) *gomock.Call

Start indicates an expected call of Start.

func (*MockEchoServerMockRecorder) TRACE

func (mr *MockEchoServerMockRecorder) TRACE(path, h any, m ...any) *gomock.Call

TRACE indicates an expected call of TRACE.

func (*MockEchoServerMockRecorder) Use

func (mr *MockEchoServerMockRecorder) Use(middleware ...any) *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, addresses []string, creatorFn func(ipHeader string) (EchoServer, error), ipHeader string) error

Bind binds the given path (first part of the URL) to the given HTTP interfaces. Calling Bind for the same path twice results in an error being returned.

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 PublicConfig

type PublicConfig 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"`
}

PublicConfig contains the configuration for outside-facing HTTP endpoints.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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