http

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PortConfigKey        = "http-port"
	GracePeriodConfigKey = "http-grace-period"
)
View Source
const DefaultGracePeriod = 3 * time.Second
View Source
const DefaultHealthEndpoint = "/health"
View Source
const DefaultLoggingMiddlewareEnabled = true
View Source
const DefaultName = "default"
View Source
const DefaultPort = "8080"
View Source
const DefaultPrometheusMiddlewareEnabled = true

Variables

This section is empty.

Functions

func Flags

func Flags() *pflag.FlagSet

Flags is a convenience function to quickly add the HTTP server options as CLI flags Implements the cli.FlagProvider type

func NewFileServer

func NewFileServer(filePath string) *swaggerHandler

Types

type Option

type Option func(*Options)

func DisableLoggingMiddleware

func DisableLoggingMiddleware() Option

func HealthEndpoint

func HealthEndpoint(endpoint string) Option

func LoggingSkipEndpoints

func LoggingSkipEndpoints(skip ...string) Option

func Name

func Name(name string) Option

func Port

func Port(addr string) Option

func ShutdownGracePeriod

func ShutdownGracePeriod(duration time.Duration) Option

type Options

type Options struct {
	Port                        string
	Name                        string
	HealthEndpoint              string
	ShutdownGracePeriod         time.Duration
	LoggingMiddlewareEnabled    bool
	PrometheusMiddlewareEnabled bool
	LoggingSkipEndpoints        []string
}

type Server

type Server interface {
	ListenAndServe(ctx context.Context, wg *sync.WaitGroup)
	Handle(endpoint string, handler http.Handler)
}

func NewDebugServer

func NewDebugServer(port string) Server

NewDebugServer is a convenience wrapper to quickly create a HTTP server, serving on port 3000. The server has the prometheus HTTP handler attached to '/metrics'.

func NewServer

func NewServer(opts ...Option) Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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