infra

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetenvDefault added in v0.0.3

func GetenvDefault(key, defaultValue string) string

GetenvDefault returns the value of environment variable called by key. If the value is undefined or in other words empty, then value of given defaultValue is returned.

func GoodTLSConfig deprecated added in v0.0.8

func GoodTLSConfig(src *tls.Config) *tls.Config

GoodTLSConfig configures a copy of given tls.Config with good settings.

Deprecated: GooldTLSConfig is unused.

func IsCI added in v0.0.5

func IsCI() bool

IsCI returns true if environment variable CI has value true and false otherwise.

func IsDevelopment added in v0.0.4

func IsDevelopment() bool

IsDevelopment checks environment variable ENV and returns true only if ENV value is `development`.

func IsProduction added in v0.0.4

func IsProduction() bool

IsProduction checks the value of environment variable ENV and returns true if value is `production`.

func Must

func Must[T any](value T, err error) T

Must checks for given err. If err is not nil panic is called, otherwise returns value T.

func RandInt64

func RandInt64() (int64, error)

RandInt64 returns cryptographically secure random number.

func TLSConfig

func TLSConfig(getCertificate GetCertificate) *tls.Config

TLSConfig returns secure TLS configuration for Internet server.

Types

type GetCertificate added in v0.11.0

type GetCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate returns a Certificate based on the given ClientHelloInfo.

func GetCertificateFromFiles added in v0.11.0

func GetCertificateFromFiles(certFile, keyFile string) GetCertificate

GetCertificateFromFiles loads GetCertificate func from given TLS cert files.

func GetCertificateFromLetsEncrypt added in v0.11.0

func GetCertificateFromLetsEncrypt(m *autocert.Manager) GetCertificate

GetCertificateFromLetsEncrypt loads GetCertificate func from given Let's Encrypt Manager.

func GetCertificateFunc deprecated added in v0.0.6

func GetCertificateFunc(m *autocert.Manager, devCertFile, devKeyFile string) GetCertificate

GetCertificateFunc loads certificates for development or production depending on return value of function [kkn.fi/infra#IsProduction].

Deprecated: GetCertificateFunc is deprecated.

func GetCertificateFuncFromFiles deprecated added in v0.0.6

func GetCertificateFuncFromFiles(certFile, keyFile string) GetCertificate

GetCertificateFuncFromFiles loads GetCertificate func from given TLS cert files.

Deprecated: GetCertificateFuncFromFiles is deprecated. Use GetCertificateFromFiles instead.

func GetCertificateFuncFromLetsEncrypt deprecated added in v0.0.6

func GetCertificateFuncFromLetsEncrypt(m *autocert.Manager) GetCertificate

GetCertificateFuncFromLetsEncrypt loads GetCertificate func from given Let's Encrypt Manager.

Deprecated: GetCertificateFuncFromFiles is deprecated. Use GetCertificateFromLetsEncrypt instead.

func GetDevelopmentCert deprecated added in v0.0.8

func GetDevelopmentCert(certFile, keyFile string) GetCertificate

Deprecated: GetDevelopmentCert is deprecated. Use GetCertificateFuncFromFiles instead.

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

Logger implements a common logger interaface compatible with standard log.Logger.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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