dockerstartproxy

package module
v0.0.0-...-322f572 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrContainerNotFound = errors.New("container not found")

ErrContainerNotFound is returned when the Docker container for a request is missing.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Path used for health probing. Defaults to "/health".
	HealthPath string `json:"health_path,omitempty"`

	// Max time to start (or find) the container and pass health checks.
	// Defaults to 30s.
	Timeout caddy.Duration `json:"timeout,omitempty"`

	// Interval between health probes. Defaults to 300ms.
	PollInterval caddy.Duration `json:"poll_interval,omitempty"`

	// Dial timeout for health probe HTTP client. Defaults to 3s.
	ProbeDialTimeout caddy.Duration `json:"probe_dial_timeout,omitempty"`

	RedirectURL  string `json:"redirect_url,omitempty"`  // e.g. "https://storrito.localhost/signup"
	RedirectCode int    `json:"redirect_code,omitempty"` // 301, 302, 303, 307, or 308 (default 307)
	// contains filtered or unexported fields
}

Handler is a Caddy HTTP middleware that ensures the derived Docker container is running and healthy before proxying the request to it.

func (Handler) CaddyModule

func (Handler) CaddyModule() caddy.ModuleInfo

Caddy module info.

func (*Handler) Provision

func (h *Handler) Provision(ctx caddy.Context) error

Provision initializes defaults and the Docker client.

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

ServeHTTP implements the middleware logic.

func (*Handler) UnmarshalCaddyfile

func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile supports a simple Caddyfile block:

docker_start_proxy {
  health_path /health
  timeout 30s
  poll_interval 300ms
  probe_dial_timeout 3s
  redirect_url https://example.com/fallback
  redirect_code 307
}

Jump to

Keyboard shortcuts

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