platform

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package platform provides logging, health endpoints, middleware and the HTTP server lifecycle.

Index

Constants

View Source
const (
	PathLive  = "/.well-known/live"
	PathReady = "/.well-known/ready"
)

Paths of the liveness and readiness probes. They are served on the same address as the WebSocket. A reverse proxy in front of the server should not expose them.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(level slog.Level) *slog.Logger

NewLogger returns a JSON logger that writes to stdout.

func OKHandler

func OKHandler() http.Handler

OKHandler returns 200 "ok". It serves the liveness probe.

func ReadyHandler

func ReadyHandler(ping func(context.Context) error) http.Handler

ReadyHandler returns 200 if ping succeeds within one second, and 503 otherwise. It serves the readiness probe.

func Recover

func Recover(log *slog.Logger, next http.Handler) http.Handler

Recover logs a panic in next and returns 500 instead of ending the process.

func Serve

func Serve(ctx context.Context, log *slog.Logger, addr string, h http.Handler, onShutdown func(context.Context) error) error

Serve runs the HTTP server until ctx is canceled and then shuts it down within shutdownTimeout. http.Server.Shutdown does not wait for hijacked connections such as WebSockets. onShutdown closes them.

Types

This section is empty.

Jump to

Keyboard shortcuts

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