startup_http

package
v2.10.51 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 21 Imported by: 2 modules, 1 package

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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."`
	// contains filtered or unexported fields
}

func (*HTTPOptions) Initialize added in v2.8.0

func (opts *HTTPOptions) Initialize(ctx context.Context, base startup_base.BaseOptions, tracingOpts *tracing.TracingOptions)

func (*HTTPOptions) Serve

func (opts *HTTPOptions) Serve(config Config)

func (*HTTPOptions) ServeHandler added in v2.8.0

func (opts *HTTPOptions) ServeHandler(handler http.Handler)

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