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 ¶
- func IsUnixSocketEnabled() bool
- func Listen(opts ListenOpts)
- func LogRequest(next Handler) http.Handler
- func PanicRecovery(next http.Handler) http.Handler
- func RegisterHttpHandler(path string, handler Handler)
- func RequestTimeoutHeaderAware(next func(w http.ResponseWriter, r *http.Request)) http.HandlerFunc
- func StopListen()
- func WaitForServe()
- func WriteBody(w http.ResponseWriter, response any)
- func WriteError(w http.ResponseWriter, err extension_kit.ExtensionError)
- type CertReloader
- type Handler
- type ListenOpts
- type ListenSpecification
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 RegisterHttpHandler ¶
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 ¶
GetterAsHandler turns a getter function into a handler function. Typically used in combination with the RegisterHttpHandler function.
func IfNoneMatchHandler ¶ added in v1.8.10
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"` }
Click to show internal directories.
Click to hide internal directories.