Documentation
¶
Index ¶
- func Must[T any](c Container, name string) T
- func MustScope[T any](s Scope, name string) T
- func RegisterInterface[I, T any](c Container, name string, factory func(Container) (T, error), ...) error
- func RegisterScoped[T any](c Container, name string, factory func(Container) (T, error)) error
- func RegisterScopedInterface[I, T any](c Container, name string, factory func(Container) (T, error)) error
- func RegisterSingleton[T any](c Container, name string, factory func(Container) (T, error)) error
- func RegisterSingletonInterface[I, T any](c Container, name string, factory func(Container) (T, error)) error
- func RegisterTransient[T any](c Container, name string, factory func(Container) (T, error)) error
- func RegisterTransientInterface[I, T any](c Container, name string, factory func(Container) (T, error)) error
- func RegisterValue[T any](c Container, name string, instance T) error
- func Resolve[T any](c Container, name string) (T, error)
- func ResolveScope[T any](s Scope, name string) (T, error)
- type Container
- type Context
- type ContextWithClean
- type Ctx
- func (c *Ctx) Bind(v any) error
- func (c *Ctx) BindJSON(v any) error
- func (c *Ctx) BindXML(v any) error
- func (c *Ctx) Bytes(code int, data []byte) error
- func (c *Ctx) Cleanup()
- func (c *Ctx) Container() Container
- func (c *Ctx) Context() context.Context
- func (c *Ctx) FormFile(name string) (multipart.File, *multipart.FileHeader, error)
- func (c *Ctx) FormFiles(name string) ([]*multipart.FileHeader, error)
- func (c *Ctx) FormValue(name string) string
- func (c *Ctx) FormValues(name string) []string
- func (c *Ctx) Get(key string) any
- func (c *Ctx) Header(key string) string
- func (c *Ctx) HealthManager() HealthManager
- func (c *Ctx) JSON(code int, v any) error
- func (c *Ctx) Metrics() Metrics
- func (c *Ctx) Must(name string) any
- func (c *Ctx) MustGet(key string) any
- func (c *Ctx) NoContent(code int) error
- func (c *Ctx) Param(name string) string
- func (c *Ctx) Params() map[string]string
- func (c *Ctx) ParseMultipartForm(maxMemory int64) error
- func (c *Ctx) Query(name string) string
- func (c *Ctx) QueryDefault(name, defaultValue string) string
- func (c *Ctx) Redirect(code int, url string) error
- func (c *Ctx) Request() *http.Request
- func (c *Ctx) Resolve(name string) (any, error)
- func (c *Ctx) Response() http.ResponseWriter
- func (c *Ctx) Scope() Scope
- func (c *Ctx) Set(key string, value any)
- func (c *Ctx) SetHeader(key, value string)
- func (c *Ctx) Status(code int) shared.ResponseBuilder
- func (c *Ctx) String(code int, s string) error
- func (c *Ctx) WithContext(ctx context.Context)
- func (c *Ctx) XML(code int, v any) error
- type DependencyGraph
- type Factory
- type HealthManager
- type Metrics
- type RegisterOption
- type ResponseBuilder
- func (rb *ResponseBuilder) Bytes(data []byte) error
- func (rb *ResponseBuilder) Header(key, value string) shared.ResponseBuilder
- func (rb *ResponseBuilder) JSON(v any) error
- func (rb *ResponseBuilder) NoContent() error
- func (rb *ResponseBuilder) String(s string) error
- func (rb *ResponseBuilder) XML(v any) error
- type Scope
- type ServiceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterInterface ¶
func RegisterInterface[I, T any](c Container, name string, factory func(Container) (T, error), opts ...RegisterOption) error
RegisterInterface registers an implementation as an interface Supports all lifecycle options (Singleton, Scoped, Transient)
func RegisterScoped ¶
RegisterScoped is a convenience wrapper for request-scoped services
func RegisterScopedInterface ¶
func RegisterScopedInterface[I, T any](c Container, name string, factory func(Container) (T, error)) error
RegisterScopedInterface is a convenience wrapper
func RegisterSingleton ¶
RegisterSingleton is a convenience wrapper
func RegisterSingletonInterface ¶
func RegisterSingletonInterface[I, T any](c Container, name string, factory func(Container) (T, error)) error
RegisterSingletonInterface is a convenience wrapper
func RegisterTransient ¶
RegisterTransient is a convenience wrapper
func RegisterTransientInterface ¶
func RegisterTransientInterface[I, T any](c Container, name string, factory func(Container) (T, error)) error
RegisterTransientInterface is a convenience wrapper
func RegisterValue ¶
RegisterValue registers a pre-built instance (always singleton)
Types ¶
type Context ¶
Context wraps http.Request with convenience methods
func NewContext ¶
NewContext creates a new context
type ContextWithClean ¶
type ContextWithClean interface {
Cleanup()
}
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
Ctx implements Context interface
func (*Ctx) Cleanup ¶
func (c *Ctx) Cleanup()
Cleanup ends the scope (should be called after request)
func (*Ctx) FormFiles ¶
func (c *Ctx) FormFiles(name string) ([]*multipart.FileHeader, error)
FormFiles retrieves multiple files with the same field name from a multipart form
func (*Ctx) FormValues ¶
FormValues retrieves all values for a form field
func (*Ctx) HealthManager ¶
func (c *Ctx) HealthManager() HealthManager
HealthManager returns the health manager
func (*Ctx) ParseMultipartForm ¶
ParseMultipartForm parses a multipart form with the specified max memory maxMemory: maximum memory in bytes to use for storing files in memory (rest goes to disk) Recommended values: 10MB (10<<20), 32MB (32<<20), 64MB (64<<20)
func (*Ctx) QueryDefault ¶
QueryDefault returns a query parameter with default value
func (*Ctx) Response ¶
func (c *Ctx) Response() http.ResponseWriter
Response returns the HTTP response writer
func (*Ctx) Status ¶
func (c *Ctx) Status(code int) shared.ResponseBuilder
Status sets the HTTP status code and returns a builder for chaining
func (*Ctx) WithContext ¶
WithContext replaces the request context
type DependencyGraph ¶
type DependencyGraph struct {
// contains filtered or unexported fields
}
DependencyGraph manages service dependencies
func NewDependencyGraph ¶
func NewDependencyGraph() *DependencyGraph
NewDependencyGraph creates a new dependency graph
func (*DependencyGraph) AddNode ¶
func (g *DependencyGraph) AddNode(name string, dependencies []string)
AddNode adds a node with its dependencies
func (*DependencyGraph) TopologicalSort ¶
func (g *DependencyGraph) TopologicalSort() ([]string, error)
TopologicalSort returns nodes in dependency order Returns error if circular dependency detected
type HealthManager ¶
type HealthManager = shared.HealthManager
type RegisterOption ¶
type RegisterOption = shared.RegisterOption
RegisterOption is a configuration option for service registration
func Scoped ¶
func Scoped() RegisterOption
Scoped makes the service live for the duration of a scope
func Transient ¶
func Transient() RegisterOption
Transient makes the service created on each resolve
func WithDIMetadata ¶
func WithDIMetadata(key, value string) RegisterOption
WithDIMetadata adds diagnostic metadata to DI service registration
func WithDependencies ¶
func WithDependencies(deps ...string) RegisterOption
WithDependencies declares explicit dependencies
func WithGroup ¶
func WithGroup(group string) RegisterOption
WithGroup adds service to a named group
type ResponseBuilder ¶
type ResponseBuilder struct {
// contains filtered or unexported fields
}
ResponseBuilder provides fluent response building
func (*ResponseBuilder) Bytes ¶
func (rb *ResponseBuilder) Bytes(data []byte) error
Bytes sends a byte response with the configured status
func (*ResponseBuilder) Header ¶
func (rb *ResponseBuilder) Header(key, value string) shared.ResponseBuilder
Header sets a response header and returns the builder for chaining
func (*ResponseBuilder) JSON ¶
func (rb *ResponseBuilder) JSON(v any) error
JSON sends a JSON response with the configured status
func (*ResponseBuilder) NoContent ¶
func (rb *ResponseBuilder) NoContent() error
NoContent sends a no-content response with the configured status
func (*ResponseBuilder) String ¶
func (rb *ResponseBuilder) String(s string) error
String sends a string response with the configured status
func (*ResponseBuilder) XML ¶
func (rb *ResponseBuilder) XML(v any) error
XML sends an XML response with the configured status
type Scope ¶
Scope represents a lifetime scope for scoped services Typically used for HTTP requests or other bounded operations
type ServiceInfo ¶
type ServiceInfo = shared.ServiceInfo
ServiceInfo contains diagnostic information