Versions in this module Expand all Collapse all v1 v1.0.1 Oct 30, 2024 Changes in this version + func AddAnnotation[T AllowedAnnotationTypes](ctx context.Context, key string, value T) + func AddMetadata(ctx context.Context, key string, value interface{}) + func AddTwirpRequestHeaders(next http.Handler, names ...string) http.Handler + func AddUserAnnotation(ctx context.Context, user string) + func AnnotationMiddleware(handler http.Handler) http.Handler + func CombineMetricsAndAuthHooks(metrics, auth *twirp.ServerHooks) *twirp.ServerHooks + func ConfigureXRay(logger *slog.Logger, version string) + func ContextWithAnnotations(ctx context.Context) context.Context + func DefaultCORSDomains() []string + func DefaultCORSMiddleware() *cors.Cors + func HealthcheckHandler(logger *slog.Logger, test HealthcheckFunc) http.Handler + func Logger(logLevel string, writer io.Writer) *slog.Logger + func NewCORSMiddleware(opts CORSOptions) *cors.Cors + func NewErrorLoggingHooks(logger *slog.Logger) *twirp.ServerHooks + func NewTwirpMetricsHooks(opts ...TwirpMetricOptionFunc) (*twirp.ServerHooks, error) + func NoopHealthcheck(_ context.Context) error + func SafeClose(logger ErrorLogger, name string, c io.Closer) + func SafeFailingClose(logger ErrorLogger, outErr *error, name string, c io.Closer) + func StandardInternalMux(logger *slog.Logger, test HealthcheckFunc) *http.ServeMux + func StandardServer(port int, handler http.Handler) *http.Server + func StandardTwirpHooks(logger *slog.Logger, opts TwirpHookOptions) (*twirp.ServerHooks, error) + type AllowedAnnotationTypes interface + type AnnotationHandler struct + func NewAnnotationHandler(opts *slog.HandlerOptions, writer io.Writer) *AnnotationHandler + func (h *AnnotationHandler) Enabled(ctx context.Context, level slog.Level) bool + func (h *AnnotationHandler) Handle(ctx context.Context, r slog.Record) error + func (h *AnnotationHandler) WithAttrs(attrs []slog.Attr) slog.Handler + func (h *AnnotationHandler) WithGroup(name string) slog.Handler + type CORSOptions struct + AllowHTTP bool + AllowedDomains []string + Custom cors.Options + type ContextAnnotations struct + func GetContextAnnotations(ctx context.Context) *ContextAnnotations + func (a *ContextAnnotations) AddAnnotation(key string, value interface{}) + func (a *ContextAnnotations) AddMetadata(key string, value interface{}) + func (a *ContextAnnotations) GetAnnotations() map[string]interface{} + func (a *ContextAnnotations) GetID() string + func (a *ContextAnnotations) GetMetadata() map[string]interface{} + func (a *ContextAnnotations) GetUser() string + func (a *ContextAnnotations) SetUser(user string) + type ErrorLogger interface + Errorf func(format string, args ...interface{}) + type HealthcheckFunc func(ctx context.Context) error + type NewServiceFunc func(hooks *twirp.ServerHooks) http.Handler + type StandardApp struct + Mux *http.ServeMux + Server *http.Server + func NewStandardApp(logger *slog.Logger, name string, opts ...StandardAppOption) (*StandardApp, error) + func (app *StandardApp) LambdaHandler() lambda.HandlerFunc + func (app *StandardApp) ListenAndServe() error + type StandardAppOption func(app *StandardApp) + func WithAppAuthHook(authHook *twirp.ServerHooks, authOrg func(ctx context.Context) string) StandardAppOption + func WithAppHealthCheck(check HealthcheckFunc) StandardAppOption + func WithAppPorts(public, internal int) StandardAppOption + func WithAppService(pathPrefix string, fn NewServiceFunc) StandardAppOption + func WithAppTestServers(ts *TestServers) StandardAppOption + func WithAppVersion(version string) StandardAppOption + func WithImasURL(imasURL string) StandardAppOption + func WithTwirpCORSOptions(opts CORSOptions) StandardAppOption + func WithTwirpMetricsOptions(opts ...TwirpMetricOptionFunc) StandardAppOption + type TestServers struct + func (ts *TestServers) Close() + func (ts *TestServers) GetInternal() *httptest.Server + func (ts *TestServers) GetPublic() *httptest.Server + type TwirpHookOptions struct + AuthHook *twirp.ServerHooks + ImasURL string + MetricsOptions []TwirpMetricOptionFunc + type TwirpMetricOptionFunc func(opts *TwirpMetricsOptions) + func WithTwirpMetricsOrgFunction(fn func(ctx context.Context) string) TwirpMetricOptionFunc + func WithTwirpMetricsRegisterer(reg prometheus.Registerer) TwirpMetricOptionFunc + func WithTwirpMetricsStaticTestLatency(latency time.Duration) TwirpMetricOptionFunc + type TwirpMetricsOptions struct