router

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0, MIT Imports: 15 Imported by: 0 modules, 0 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

Overview

Package router is Skiff's edge router: it discovers apps from Docker labels and reverse-proxies <app>.<domain> to them, with automatic HTTPS. It runs on the server. Reserved hosts: dash.<domain> → the control panel, status.<domain> → a live status page, and the apex + www.<domain> → a designated site app.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	T      int64 `json:"t"` // minute, unix seconds (floored)
	Req    int   `json:"req"`
	S2     int   `json:"s2"`
	S3     int   `json:"s3"`
	S4     int   `json:"s4"`
	S5     int   `json:"s5"`
	LatMs  int64 `json:"lat"` // summed latency in ms (÷ Req for the average)
	BytesI int64 `json:"bi"`  // request bytes in
	BytesO int64 `json:"bo"`  // response bytes out
}

Bucket is one minute of traffic for an app.

type Metrics

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

func NewMetrics

func NewMetrics(file string) *Metrics

func (*Metrics) Record

func (m *Metrics) Record(app string, status int, bytesIn, bytesOut int64, dur time.Duration)

Record adds one request to the current minute's bucket for an app.

func (*Metrics) Run

func (m *Metrics) Run()

Run prunes the window and snapshots to disk on a fixed cadence, for the life of the process.

type Router

type Router struct {
	Domains []string
	Engine  *docker.Engine
	Panel   string // fallback host:port of the control panel; dash.<domain> proxies here
	// PanelPointer, when set, is a file holding the current panel host:port. The
	// panel can rewrite it during a zero-downtime self-deploy to flip dash.<domain>
	// onto the freshly-built process, so the router itself never restarts.
	PanelPointer string
	SiteApp      string // app that serves the apex + www.<domain>
	// DomainsFile, when set, is a JSON file of custom host→app mappings the panel
	// maintains. The router reads it live (cached briefly) so domains can be added
	// or removed without restarting the edge.
	DomainsFile string
	// MetricsFile, when set, is where the router snapshots per-app request metrics
	// for the panel's Analytics page.
	MetricsFile string
	// contains filtered or unexported fields
}

func (*Router) ServeHTTP

func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Router) ServeHTTPOnly

func (rt *Router) ServeHTTPOnly(addr string) error

ServeHTTPOnly runs the router over plain HTTP (for local testing, no TLS).

func (*Router) ServeTLS

func (rt *Router) ServeTLS(cacheDir string) error

ServeTLS runs :443 with Let's Encrypt certs and :80 for ACME challenges + an HTTP→HTTPS redirect.

Jump to

Keyboard shortcuts

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