ingress

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PortHTTP is the port for http traffic.
	PortHTTP = 80

	// PortHTTPS is the port for https traffic.
	PortHTTPS = 443
)

Variables

This section is empty.

Functions

func Service

func Service(configurators ...Configurator) host.Configurator

Service returns ingress service.

Types

type Config

type Config struct {
	// WaveServers are addresses of wave servers.
	WaveServers []string

	// Targets defines target registrations for endpoint.
	Targets map[EndpointID][]TargetConfig

	// Endpoints defines HTTP endpoints inside HTTPIngress.
	Endpoints map[EndpointID]EndpointConfig
}

Config defines configuration of HTTP HTTPIngress.

type Configurator

type Configurator func(c *Config)

Configurator is the function configuring ingress.

func Endpoint

func Endpoint(endpointID EndpointID, configurators ...EndpointConfigurator) Configurator

Endpoint adds endpoint to the ingress.

func Target

func Target(endpointID EndpointID, host string, port uint16, path string) Configurator

Target adds target for an endpoint.

func Waves

func Waves(waves ...string) Configurator

Waves adds wave servers to send challenge requests to.

type EndpointConfig

type EndpointConfig struct {
	// Path is a prefix service is available under.
	Path string

	// HTTPSMode defines how https traffic is handled.
	HTTPSMode HTTPSMode

	// PlainBindings specify endpoints in form <ip>:<port> which HTTPIngress binds to for http traffic.
	PlainBindings []string

	// TLSBindings specify endpoints in form <ip>:<port> which HTTPIngress binds to for https traffic.
	TLSBindings []string

	// AllowedDomains are domains requests are accepted for.
	AllowedDomains []string

	// AllowedMethods are allowed http methods.
	AllowedMethods []string

	// AllowWebsockets enables websocket connections.
	AllowWebsockets bool

	// MaxBodyLength defines maximum size of request body.
	MaxBodyLength int64

	// RemoveWWWPrefix causes redirection to URL with `www.` prefix removed.
	RemoveWWWPrefix bool

	// AddSlashToDirs redirects to the path with slash (/) added at the end if there is no dot (.) in last segment.
	AddSlashToDirs bool
}

EndpointConfig describes configuration of http HTTPIngress endpoint.

type EndpointConfigurator

type EndpointConfigurator func(c *EndpointConfig)

EndpointConfigurator is the function configuring endpoint.

func AddSlash

func AddSlash() EndpointConfigurator

AddSlash causes redirection to slash-suffixed URL if URL does not end with slash or dotted (.sth) suffix.

func BodyLimit

func BodyLimit(limit int64) EndpointConfigurator

BodyLimit sets the maximum allowed size of the request body in bytes. Requests exceeding this limit will be rejected.

func Domains

func Domains(domains ...string) EndpointConfigurator

Domains sets serviced domains.

func EnableWebsockets

func EnableWebsockets() EndpointConfigurator

EnableWebsockets enables websockets.

func HTTPS

func HTTPS(httpsMode HTTPSMode) EndpointConfigurator

HTTPS configures mode of https operation.

func Methods

func Methods(methods ...string) EndpointConfigurator

Methods sets serviced HTTP methods.

func Path

func Path(path string) EndpointConfigurator

Path sets path for the endpoint.

func PlainBindings

func PlainBindings(bindings ...string) EndpointConfigurator

PlainBindings configures socket bindings for HTTP.

func RemoveWWW

func RemoveWWW() EndpointConfigurator

RemoveWWW causes redirection of www.* domains to non-www ones.

func TLSBindings

func TLSBindings(bindings ...string) EndpointConfigurator

TLSBindings configures socket bindings for HTTPS.

type EndpointID

type EndpointID string

EndpointID is an id of HTTPIngress endpoint.

type HTTPIngress

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

HTTPIngress is the http ingress.

func New

func New(cfg Config) *HTTPIngress

New creates new http ingress.

func (*HTTPIngress) Run

func (i *HTTPIngress) Run(ctx context.Context) (retErr error)

Run runs the ingress servers.

type HTTPSMode

type HTTPSMode string

HTTPSMode defines how https traffic is handled by http HTTPIngress endpoint.

const (
	// HTTPSModeDisabled causes HTTPIngress to work in http mode only.
	HTTPSModeDisabled HTTPSMode = "disabled"

	// HTTPSModeOptional causes HTTPIngress to work in both http and https modes.
	HTTPSModeOptional HTTPSMode = "optional"

	// HTTPSModeRedirect causes HTTPIngress to redirect client from http to https.
	HTTPSModeRedirect HTTPSMode = "redirect"

	// HTTPSModeOnly causes HTTPIngress to run only https endpoint, http just won't respond at all.
	HTTPSModeOnly HTTPSMode = "only"
)

type TargetConfig

type TargetConfig struct {
	Host string
	Port uint16
	Path string
}

TargetConfig represents target registration.

Jump to

Keyboard shortcuts

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