httpserver

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PemTypePrivateKey  = "PRIVATE KEY"
	PemTypeCertificate = "CERTIFICATE"
)

Variables

This section is empty.

Functions

func ListenAddr

func ListenAddr(listen string, tls bool) string

ListenAddr resolves a listen address string into a host:port pair, applying defaults for missing host or port. When tls is true the default port is "https" (443); otherwise it is "http" (80).

func New

func New(listen string, router http.Handler, cert *tls.Config, opts ...Opt) (*server, error)

func TLSConfig

func TLSConfig(name string, verify bool, data ...[]byte) (*tls.Config, error)

TLSConfig creates a tls.Config from raw PEM-encoded certificate and key data. The data slices may each contain a single PEM block, or they may be concatenated (cert + key in one slice). name sets the ServerName field; when verify is false, client certificate verification is skipped.

func ValidateCert

func ValidateCert(cert, key []byte) error

ValidateCert checks that the given PEM-encoded certificate and key form a valid key pair and that the leaf certificate has not expired. It is intended for use at plan time to catch configuration errors before Apply.

Types

type Opt

type Opt func(*opt) error

func WithIdleTimeout

func WithIdleTimeout(v time.Duration) Opt

Set the idle timeout for keep-alive connections

func WithReadTimeout

func WithReadTimeout(v time.Duration) Opt

Set the read timeout for the HTTP server

func WithWriteTimeout

func WithWriteTimeout(v time.Duration) Opt

Set the write timeout for the HTTP server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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