startup_http

package
v2.5.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSignalHandlerForServer

func RegisterSignalHandlerForServer(server *http.Server) <-chan struct{}

func WithPrometheusMetrics added in v2.4.11

func WithPrometheusMetrics(s string) admin.RouteConfig

Types

type Config

type Config struct {
	// name for the service. Will be used in the admin panel
	Name string

	// Routing configuration. You can use the supplied router or
	// return your own handler.
	Routing func(*http.ServeMux) http.Handler

	// Extra admin handlers to register on the admin page
	AdminHandlers []admin.RouteConfig

	// Registers a shutdown handler for the http server. If not set,
	// a default signal handler for clean shutdown on SIGINT and SIGTERM is used.
	RegisterSignalHandlerForServer func(*http.Server) <-chan struct{}

	// Wrap the http server with this middleware in the end. A good example would
	// be to use a tracing middleware at this point.
	UseMiddleware HttpMiddleware
}

type HTTPOptions

type HTTPOptions struct {
	Address string `long:"http-address" env:"HTTP_ADDRESS" default:":3080" description:"Address to listen on."`

	TLSKeyFile  string `long:"http-tls-key" env:"HTTP_TLS_KEY" description:"Private key file to enable SSL support."`
	TLSCertFile string `long:"http-tls-cert" env:"HTTP_TLS_CERT" description:"Certificate file to enable SSL support."`

	DisableAdminRedirect bool   `long:"http-disable-admin-redirect" env:"HTTP_DISABLE_ADMIN_REDIRECT" description:"Disable admin redirect on /"`
	DisableAuth          bool   `long:"http-disable-admin-auth" env:"HTTP_DISABLE_ADMIN_AUTH" description:"Disable basic auth"`
	BasicAuthUsername    string `long:"http-admin-username" env:"HTTP_ADMIN_USERNAME" default:"admin" description:"Basic auth username for admin panel."`
	BasicAuthPassword    string `long:"http-admin-password" env:"HTTP_ADMIN_PASSWORD" default:"bingo" description:"Basic auth password for admin panel."`

	AccessLog            string `long:"http-access-log" env:"HTTP_ACCESS_LOG" description:"Write http access log to a file. Defaults to stdout."`
	AccessLogAdminRoute  bool   `` /* 136-byte string literal not displayed */
	AdminPageShowEnvVars bool   `long:"http-admin-show-env-vars" env:"HTTP_ADMIN_SHOW_ENV_VARS" description:"Show environment variables on the admin page."`
}

func (HTTPOptions) Serve

func (opts HTTPOptions) Serve(config Config)

type HttpMiddleware

type HttpMiddleware func(http.Handler) http.Handler

type SlogRecoveryHandlerLogger added in v2.4.20

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

SlogRecoveryHandlerLogger implements the handlers.RecoveryHandlerLogger interface by logging panic details at slog.LevelError in JSON format.

func NewSlogRecoveryHandlerLogger added in v2.4.20

func NewSlogRecoveryHandlerLogger() *SlogRecoveryHandlerLogger

NewSlogRecoveryHandlerLogger creates and returns a new SlogRecoveryHandlerLogger.

func (*SlogRecoveryHandlerLogger) Println added in v2.4.20

func (l *SlogRecoveryHandlerLogger) Println(v ...any)

Println implements the handlers.RecoveryHandlerLogger interface. It receives the arguments from RecoveryHandler (typically panic_value, stack_trace_string) and logs them as structured JSON at slog.LevelError.

Jump to

Keyboard shortcuts

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