exthttp

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 26 Imported by: 60

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 BumpRevision added in v1.11.0

func BumpRevision()

BumpRevision advances the index revision. Kit SDKs call this from their Register*/Clear* functions whenever the set of registered describable elements changes.

func IsUnixSocketEnabled added in v1.8.0

func IsUnixSocketEnabled() bool

func Listen added in v1.6.0

func Listen(opts ListenOpts)

func LogRequestWithDefaultLogLevel added in v1.8.23

func LogRequestWithDefaultLogLevel(next Handler, defaultLevel zerolog.Level) 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, gzip compression and request logging around the handler.

func RegisterHttpHandlerWithLogLevel added in v1.8.23

func RegisterHttpHandlerWithLogLevel(path string, handler Handler, defaultLevel zerolog.Level)

RegisterHttpHandlerWithLogLevel registers a handler for the given path. Also adds panic recovery, gzip compression and request logging with a given log level around the handler.

func RegisterRevisionedHandler added in v1.11.0

func RegisterRevisionedHandler[T any](path string, getter func() T)

RegisterRevisionedHandler registers a handler that serves the getter's result at path, tagging the response with the current Revision() as its ETag so it supports conditional GET (a matching If-None-Match yields 304). Use this instead of hand-rolling IfNoneMatchHandler with a process-start timestamp, e.g. for the combined extension index.

func RequestTimeoutHeaderAware added in v1.7.4

func RequestTimeoutHeaderAware(next http.Handler) http.HandlerFunc

func Revision added in v1.11.0

func Revision() string

Revision returns the current index revision string. It changes on process start and whenever any kit registers/unregisters a describable element, so it is a safe ETag for the combined index.

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"`
	EnablePprof   bool     `json:"enablePprof" split_words:"true" required:"false"`
}

Jump to

Keyboard shortcuts

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