exthttp

package
v1.8.22 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 24 Imported by: 43

Documentation

Overview

Package exthttp supports setup of HTTP servers to implement the *Kit contracts. To keep the resulting binary small the net/http server is used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnixSocketEnabled added in v1.8.0

func IsUnixSocketEnabled() bool

func Listen added in v1.6.0

func Listen(opts ListenOpts)

func LogRequest

func LogRequest(next Handler) http.Handler

func PanicRecovery

func PanicRecovery(next http.Handler) http.Handler

func RegisterHttpHandler

func RegisterHttpHandler(path string, handler Handler)

RegisterHttpHandler registers a handler for the given path. Also adds panic recovery and request logging around the handler.

func RequestTimeoutHeaderAware added in v1.7.4

func RequestTimeoutHeaderAware(next func(w http.ResponseWriter, r *http.Request)) http.HandlerFunc

func StopListen added in v1.8.15

func StopListen()

func WaitForServe added in v1.8.15

func WaitForServe()

func WriteBody

func WriteBody(w http.ResponseWriter, response any)

WriteBody writes the given value as the HTTP response body as JSON with status code 200.

func WriteError

func WriteError(w http.ResponseWriter, err extension_kit.ExtensionError)

WriteError writes the error as the HTTP response body with status code 500.

Types

type CertReloader added in v1.8.3

type CertReloader struct {
	CertFile string
	KeyFile  string
	// contains filtered or unexported fields
}

func NewCertReloader added in v1.8.3

func NewCertReloader(certFile, keyFile string) *CertReloader

func (*CertReloader) GetCertificate added in v1.8.3

func (cr *CertReloader) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)

type Handler added in v1.8.10

type Handler func(w http.ResponseWriter, r *http.Request, body []byte)

func GetterAsHandler

func GetterAsHandler[T any](handler func() T) Handler

GetterAsHandler turns a getter function into a handler function. Typically used in combination with the RegisterHttpHandler function.

func IfNoneMatchHandler added in v1.8.10

func IfNoneMatchHandler(etagFn func() string, delegate Handler) Handler

type ListenOpts added in v1.6.0

type ListenOpts struct {
	// Port Default port to bind to. Can be overridden through the environment variable STEADYBIT_EXTENSION_PORT.
	Port int
}

type ListenSpecification added in v1.6.0

type ListenSpecification struct {
	Port          int      `json:"port" split_words:"true" required:"false"`
	UnixSocket    string   `json:"unixSocket" split_words:"true" required:"false"`
	TlsServerCert string   `json:"tlsServerCert" split_words:"true" required:"false"`
	TlsServerKey  string   `json:"tlsServerKey" split_words:"true" required:"false"`
	TlsClientCas  []string `json:"tlsClientCas" split_words:"true" required:"false"`
}

Jump to

Keyboard shortcuts

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