server

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPServerConfiguration

type HTTPServerConfiguration struct {
	Host               string        `envconfig:"HTTP_HOST" default:""`
	Port               int           `envconfig:"HTTP_PORT" default:"80"`
	RequestTimeout     time.Duration `envconfig:"HTTP_REQUEST_TIMEOUT" default:"30s"`
	UserID             string        `envconfig:"USER_ID" default:""`
	CertificateFile    string        `envconfig:"CERTIFICATE_FILE" default:"/etc/tls/tls.crt"`
	CertificateKeyFile string        `envconfig:"CERTIFICATE_KEY_FILE" default:"/etc/tls/tls.key"`
	HealthzEndpoint    string        `envconfig:"HEALTHZ_ENDPOINT" default:"/healthz"`
	ReadyzEndpoint     string        `envconfig:"READYZ_ENDPOINT" default:"/readyz"`
}

HTTPServerConfiguration is a struct that holds all the environment variables required to the HTTP server

func (*HTTPServerConfiguration) LoadFromEnvVars

func (h *HTTPServerConfiguration) LoadFromEnvVars() error

LoadFromEnvVars reads all env vars required for the server package

type Server

type Server interface {
	Router() *gin.Engine

	AddHealthz(urls ...string)
	AddReadyz(status *func() bool, urls ...string)

	Run(ctx context.Context, readyCallbacks ...func())
	RunSecurely(ctx context.Context, readyCallbacks ...func())

	// NamespaceValidation checks if namespace is in the query params
	NamespaceValidation() gin.HandlerFunc
}

Server represents a HTTP Server with gin router and health probes

func NewServer

func NewServer(logger logging.Logger, configuration HTTPServerConfiguration) Server

NewServer initializes a server

Jump to

Keyboard shortcuts

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