httpserver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HealthzPort int    = 0  // expose var to be able to operator
	HealthzPath string = "" // expose var to be able to operator

	DefaultFuncHealthz HealthzFunc = func() (bool, error) {
		_, err := net.DialTimeout("tcp", models.HealthzDefaultAddr, timeoutR)
		if err != nil {
			return false, err
		}
		return true, nil
	}
)

Functions

func Init

Function to initialize application, return app struct and a func waitgroup. The app contains a map of server. By default, the app contains a healthz and metrics server.

Types

type CancelFunc

type CancelFunc func()

type HealthzFunc

type HealthzFunc func() (bool, error)

Function to check the health of the application

type InterfaceServer

type InterfaceServer interface {
	// Start all server listed in the app struct
	Run() (err error)
	// Add a new server to the app without endpoint.
	// return a server where you can add endpoint GET, POST, PUT, DELETE...
	Add(name string, opts ...Option) (s *server, err error)
}

InterfaceSerever is an interface to manage the server Run: Start the server Add: Add a new server

type Option

type Option func(s *server)

OptionsHTTP is a function to set the http server

func WithAddr

func WithAddr(addr string) Option

Function to set the address of the server addr must be like "ipv4:1-65535" addr must be an IPV4 format and with a port number between 1 and 65535 if addr is not correct, the default local address is set

func WithTLS

func WithTLS(tlsC *tls.Config) Option

Function to set the TLS configuration

type OptionServer

type OptionServer func(a *app)

OptionsServer is a function to disable some server

func DisableHealth

func DisableHealth() OptionServer

Function to disable the health server

func DisableMetrics

func DisableMetrics() OptionServer

Function to disable the metrics server

func WithCustomHandlerForHealth

func WithCustomHandlerForHealth(req HealthzFunc) OptionServer

Function WithCustomHandlerForHealth return a function Option Function take in parameter a function that return a boolean and an error and the endpoint path (e.g. /healthz)

Jump to

Keyboard shortcuts

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