web

package
v1.10.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPWhitelist added in v1.4.0

func IPWhitelist(whitelist []string) func(next http.Handler) http.Handler

IPWhitelist returns a middleware that checks if the IP of the client is in the whitelist. It always checks against the original TCP connection IP (stored in context by newRealIPMiddleware), so the whitelist cannot be bypassed via forwarded headers.

func SetExampleCert

func SetExampleCert(cert models.Entry)

SetExampleCert sets the example certificate to be used in the example endpoints.

Types

type Server added in v1.10.0

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

Server is a struct that holds the necessary information to run a webserver. It is used for the websocket server as well as the metrics server.

func NewMetricsServer

func NewMetricsServer(networkIf string, port int, certPath, keyPath string) *Server

NewMetricsServer creates a new webserver that listens on the given port and provides metrics for a metrics server.

func NewWebsocketServer

func NewWebsocketServer(networkIf string, port int, certPath, keyPath string) *Server

NewWebsocketServer starts a new webserver and initialized it with the necessary routes. It also takes care of setting up websocket.Upgrader.

func (*Server) RegisterPrometheus added in v1.10.0

func (ws *Server) RegisterPrometheus(url string, callback func(w io.Writer, exposeProcessMetrics bool))

RegisterPrometheus registers a new handler that listens on the given url and calls the given function in order to provide metrics for a prometheus server. This function signature was used, because VictoriaMetrics offers exactly this function signature.

func (*Server) Start added in v1.10.0

func (ws *Server) Start()

Start initializes the webserver and starts listening for connections.

func (*Server) Stop added in v1.10.0

func (ws *Server) Stop()

Stop tries to stop the webserver gracefully. If it doesn't stop within 15 seconds, it is forcefully closed.

Jump to

Keyboard shortcuts

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