Documentation ¶
Index ¶
- func Chain(base http.Handler, interceptors ...HTTPInterceptor) http.Handler
- func ChainF(base func(http.ResponseWriter, *http.Request), interceptors ...HTTPInterceptor) http.Handler
- func FromBytes[T any](baseSchema, appSchema string, config []byte) (conf T, err error)
- func ManageK8s(ctx context.Context, lg *slog.Logger, c HTTPConfig, cd HTTPConfig, ...) error
- func NewLog(ctx context.Context, c LogConfig) (*slog.Logger, slog.Handler, http.Handler, error)
- func NewMetric(ctx context.Context, c MetricConfig) error
- func NewO11y(c O11yConfig) (O11y, O11yReg)
- func NewTrace(ctx context.Context, c TraceConfig) (http.Handler, error)
- func Run[C, A any](r RunConfig[C, A]) (exitCode int)
- type Config
- type HTTPConfig
- type HTTPInterceptor
- type HTTPRegistrar
- type LogConfig
- type MetricConfig
- type O11y
- type O11yConfig
- type O11yReg
- type RunConfig
- type Store
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chain ¶
func Chain(base http.Handler, interceptors ...HTTPInterceptor) http.Handler
Chain chains together interceptors (middleware), the first interceptor will be the outermost.
func ChainF ¶
func ChainF(base func(http.ResponseWriter, *http.Request), interceptors ...HTTPInterceptor) http.Handler
func ManageK8s ¶
func ManageK8s(ctx context.Context, lg *slog.Logger, c HTTPConfig, cd HTTPConfig, mx *muxRegister) error
func NewO11y ¶
func NewO11y(c O11yConfig) (O11y, O11yReg)
Types ¶
type Config ¶
type Config[AppConfig any] struct { O11y O11yConfig HTTP HTTPConfig Debug HTTPConfig GRPC gRPCConfig App AppConfig }
Config is the base config type for all applications. It carries common config, and embeds application specific config
type HTTPConfig ¶
type HTTPConfig struct { // host:port listening address Address string K8s struct { Enable bool GatewayNamespace string GatewayName string } }
HTTPConfig is the config for an http server
type HTTPRegistrar ¶
type HTTPRegistrar interface { Handle(string, http.Handler) Pattern(method, host, pattern string, handler func(http.ResponseWriter, *http.Request), interceptors ...HTTPInterceptor) }
type MetricConfig ¶
type MetricConfig struct{}
type O11yConfig ¶
type O11yConfig struct { Log LogConfig Metric MetricConfig Trace TraceConfig }
type RunConfig ¶
type RunConfig[C, A any] struct { // A cue schema, all config should be under the "App" key. AppConfigSchema string // New creates an application struct from the application config struct. New func(context.Context, C, *blob.Bucket, O11y) (*A, error) // HTTP is for registering http handlers to the main listener HTTP func(*A, HTTPRegistrar) // Debug is for registering http handlers to the debug handler Debug func(*A, HTTPRegistrar) // StartTasks should use the given function to start any background tasks. // Tasks should exit when the given context is canceled. StartTasks func(*A, context.Context, func(func() error)) // RegisterShutdown should use the given function to start any tasks // that should run on shutdown. // shutdown tasks are given a context with a 5 second timeout. RegisterShutdown func(*A, context.Context, func(func(context.Context) error)) }
RunConfig are the args passed to Run. It takes 2 type parameters: C is the application config type, A is the application type.
type TraceConfig ¶
type TraceConfig struct{}
Click to show internal directories.
Click to hide internal directories.