web

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 17 Imported by: 356

README

web package

This package can be used by Prometheus exporters to enable TLS and authentication.

We actively encourage the community to use this repository, to provide a consistent experience across the ecosystem.

Developers documentation can be found on pkg.go.dev.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigToTLSConfig

func ConfigToTLSConfig(c *TLSStruct) (*tls.Config, error)

ConfigToTLSConfig generates the golang tls.Config from the TLSStruct config.

func Listen deprecated

func Listen(server *http.Server, tlsConfigPath string, logger log.Logger) error

Listen starts the server on the given address. Based on the file tlsConfigPath, TLS or basic auth could be enabled.

Deprecated: Use ListenAndServe instead.

func ListenAndServe

func ListenAndServe(server *http.Server, tlsConfigPath string, logger log.Logger) error

ListenAndServe starts the server on the given address. Based on the file tlsConfigPath, TLS or basic auth could be enabled.

func Serve

func Serve(l net.Listener, server *http.Server, tlsConfigPath string, logger log.Logger) error

Server starts the server on the given listener. Based on the file tlsConfigPath, TLS or basic auth could be enabled.

func Validate

func Validate(tlsConfigPath string) error

Validate configuration file by reading the configuration and the certificates.

Types

type Config

type Config struct {
	TLSConfig  TLSStruct                     `yaml:"tls_server_config"`
	HTTPConfig HTTPStruct                    `yaml:"http_server_config"`
	Users      map[string]config_util.Secret `yaml:"basic_auth_users"`
}

type HTTPStruct

type HTTPStruct struct {
	HTTP2  bool              `yaml:"http2"`
	Header map[string]string `yaml:"headers,omitempty"`
}

type TLSStruct

type TLSStruct struct {
	TLSCertPath              string     `yaml:"cert_file"`
	TLSKeyPath               string     `yaml:"key_file"`
	ClientAuth               string     `yaml:"client_auth_type"`
	ClientCAs                string     `yaml:"client_ca_file"`
	CipherSuites             []cipher   `yaml:"cipher_suites"`
	CurvePreferences         []curve    `yaml:"curve_preferences"`
	MinVersion               tlsVersion `yaml:"min_version"`
	MaxVersion               tlsVersion `yaml:"max_version"`
	PreferServerCipherSuites bool       `yaml:"prefer_server_cipher_suites"`
}

func (*TLSStruct) SetDirectory

func (t *TLSStruct) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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