Documentation
¶
Index ¶
- type ApplicationOption
- type Context
- func (c *Context) BindJSON(obj any) error
- func (c *Context) Body() ([]byte, error)
- func (c *Context) Context() context.Context
- func (c *Context) Data(code int, contentType string, data []byte) error
- func (c *Context) Get(key string) any
- func (c *Context) GetBool(key string) bool
- func (c *Context) GetInt(key string) int
- func (c *Context) GetString(key string) string
- func (c *Context) HTML(code int, html string) error
- func (c *Context) Header(name string) string
- func (c *Context) JSON(code int, obj any) error
- func (c *Context) Method() string
- func (c *Context) Param(name string) string
- func (c *Context) Path() string
- func (c *Context) Query(name string) string
- func (c *Context) QueryDefault(name, defaultValue string) string
- func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
- func (c *Context) Set(key string, value any)
- func (c *Context) SetContext(ctx context.Context)
- func (c *Context) SetHeader(name, value string)
- func (c *Context) SetParam(name, value string)
- func (c *Context) Status(code int) *Context
- func (c *Context) StatusCode() int
- func (c *Context) String(code int, format string, values ...any) error
- type Controller
- type ControllerMetadata
- type ControllerRef
- type HandlerFunc
- type LifecycleHookOrder
- type LifecycleManager
- func (lm *LifecycleManager) CallOnApplicationBootstrap(ctx context.Context) error
- func (lm *LifecycleManager) CallOnApplicationShutdown(ctx context.Context) error
- func (lm *LifecycleManager) CallOnModuleDestroy(ctx context.Context) error
- func (lm *LifecycleManager) CallOnModuleInit(ctx context.Context) error
- func (lm *LifecycleManager) RegisterModule(module *ModuleRef)
- type MetadataKey
- type MetadataStorage
- func (ms *MetadataStorage) Clear(target any)
- func (ms *MetadataStorage) Delete(target any, key MetadataKey)
- func (ms *MetadataStorage) Get(target any, key MetadataKey) (any, bool)
- func (ms *MetadataStorage) GetAll(target any) map[MetadataKey]any
- func (ms *MetadataStorage) Has(target any, key MetadataKey) bool
- func (ms *MetadataStorage) Set(target any, key MetadataKey, value any)
- type MiddlewareFunc
- type Module
- type ModuleBuilder
- type ModuleCompiler
- type ModuleMetadata
- type ModuleRef
- func (mr *ModuleRef) ExportProvider(providerType reflect.Type, instance any)
- func (mr *ModuleRef) GetControllers() []ControllerRef
- func (mr *ModuleRef) GetProvider(providerType reflect.Type) (any, bool)
- func (mr *ModuleRef) Name() string
- func (mr *ModuleRef) RegisterController(instance any) error
- func (mr *ModuleRef) RegisterProvider(providerType reflect.Type, instance any)
- type NestApplication
- type NestFactory
- type OnApplicationBootstrap
- type OnApplicationShutdown
- type OnModuleDestroy
- type OnModuleInit
- type ParameterMetadata
- type Provider
- type RouteDefinition
- type RouteMetadata
- type Router
- func (r *Router) Delete(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Get(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Head(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Options(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Patch(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Post(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Put(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
- func (r *Router) Register(route RouteDefinition)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Use(middleware MiddlewareFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicationOption ¶
type ApplicationOption func(*NestApplication)
ApplicationOption configures the NestApplication
func WithIdleTimeout ¶
func WithIdleTimeout(timeout time.Duration) ApplicationOption
WithIdleTimeout sets the HTTP server idle timeout
func WithReadTimeout ¶
func WithReadTimeout(timeout time.Duration) ApplicationOption
WithReadTimeout sets the HTTP server read timeout
func WithShutdownTimeout ¶
func WithShutdownTimeout(timeout time.Duration) ApplicationOption
WithShutdownTimeout sets the graceful shutdown timeout
func WithWriteTimeout ¶
func WithWriteTimeout(timeout time.Duration) ApplicationOption
WithWriteTimeout sets the HTTP server write timeout
type Context ¶
type Context struct {
Request *http.Request
Response http.ResponseWriter
// contains filtered or unexported fields
}
Context represents the request context with helper methods
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request) *Context
NewContext creates a new request context
func (*Context) QueryDefault ¶
QueryDefault returns a query parameter with a default value
func (*Context) Reset ¶
func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
Reset resets the context for reuse
func (*Context) SetContext ¶
SetContext sets the underlying context.Context
func (*Context) StatusCode ¶
StatusCode returns the response status code
type Controller ¶
type Controller interface {
Routes() []RouteDefinition
}
Controller represents a request handler with routes
type ControllerMetadata ¶
ControllerMetadata stores controller-specific metadata
type ControllerRef ¶
type ControllerRef struct {
// contains filtered or unexported fields
}
ControllerRef represents a controller instance
type HandlerFunc ¶
HandlerFunc is the signature for route handlers
type LifecycleHookOrder ¶
type LifecycleHookOrder int
LifecycleHookOrder defines the order of lifecycle hooks
const ( // OnModuleInitOrder - called when module dependencies are resolved OnModuleInitOrder LifecycleHookOrder = iota // OnApplicationBootstrapOrder - called when all modules are initialized OnApplicationBootstrapOrder // OnModuleDestroyOrder - called when module is being destroyed OnModuleDestroyOrder // OnApplicationShutdownOrder - called before application shutdown OnApplicationShutdownOrder )
func (LifecycleHookOrder) String ¶
func (o LifecycleHookOrder) String() string
String returns the string representation of lifecycle hook order
type LifecycleManager ¶
type LifecycleManager struct {
// contains filtered or unexported fields
}
LifecycleManager manages application and module lifecycle hooks
func NewLifecycleManager ¶
func NewLifecycleManager() *LifecycleManager
NewLifecycleManager creates a new lifecycle manager
func (*LifecycleManager) CallOnApplicationBootstrap ¶
func (lm *LifecycleManager) CallOnApplicationBootstrap(ctx context.Context) error
CallOnApplicationBootstrap calls OnApplicationBootstrap on all components
func (*LifecycleManager) CallOnApplicationShutdown ¶
func (lm *LifecycleManager) CallOnApplicationShutdown(ctx context.Context) error
CallOnApplicationShutdown calls OnApplicationShutdown on all components
func (*LifecycleManager) CallOnModuleDestroy ¶
func (lm *LifecycleManager) CallOnModuleDestroy(ctx context.Context) error
CallOnModuleDestroy calls OnModuleDestroy on all modules and their providers
func (*LifecycleManager) CallOnModuleInit ¶
func (lm *LifecycleManager) CallOnModuleInit(ctx context.Context) error
CallOnModuleInit calls OnModuleInit on all modules and their providers
func (*LifecycleManager) RegisterModule ¶
func (lm *LifecycleManager) RegisterModule(module *ModuleRef)
RegisterModule registers a module for lifecycle management
type MetadataKey ¶
type MetadataKey string
MetadataKey is a type for metadata keys
const ( // MetadataKeyCONTROLLER marks a type as a controller MetadataKeyCONTROLLER MetadataKey = "controller" // MetadataKeyROUTE stores route information MetadataKeyROUTE MetadataKey = "route" // MetadataKeyGUARD stores guard information MetadataKeyGUARD MetadataKey = "guard" // MetadataKeyINTERCEPTOR stores interceptor information MetadataKeyINTERCEPTOR MetadataKey = "interceptor" // MetadataKeyPIPE stores pipe information MetadataKeyPIPE MetadataKey = "pipe" // MetadataKeyPARAM stores parameter information MetadataKeyPARAM MetadataKey = "param" // MetadataKeySWAGGER stores swagger documentation MetadataKeySWAGGER MetadataKey = "swagger" )
type MetadataStorage ¶
type MetadataStorage struct {
// contains filtered or unexported fields
}
MetadataStorage stores metadata for types
func NewMetadataStorage ¶
func NewMetadataStorage() *MetadataStorage
NewMetadataStorage creates a new metadata storage
func (*MetadataStorage) Clear ¶
func (ms *MetadataStorage) Clear(target any)
Clear removes all metadata for a type
func (*MetadataStorage) Delete ¶
func (ms *MetadataStorage) Delete(target any, key MetadataKey)
Delete removes metadata for a type and key
func (*MetadataStorage) Get ¶
func (ms *MetadataStorage) Get(target any, key MetadataKey) (any, bool)
Get retrieves metadata for a type
func (*MetadataStorage) GetAll ¶
func (ms *MetadataStorage) GetAll(target any) map[MetadataKey]any
GetAll retrieves all metadata for a type
func (*MetadataStorage) Has ¶
func (ms *MetadataStorage) Has(target any, key MetadataKey) bool
Has checks if metadata exists for a type and key
func (*MetadataStorage) Set ¶
func (ms *MetadataStorage) Set(target any, key MetadataKey, value any)
Set stores metadata for a type
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc is the signature for middleware functions
type Module ¶
type Module interface {
Configure(builder *ModuleBuilder)
}
Module defines the interface that all modules must implement
type ModuleBuilder ¶
type ModuleBuilder struct {
// contains filtered or unexported fields
}
ModuleBuilder helps build module configurations
func (*ModuleBuilder) Controllers ¶
func (b *ModuleBuilder) Controllers(controllers ...any) *ModuleBuilder
Controllers adds controllers to the module
func (*ModuleBuilder) Exports ¶
func (b *ModuleBuilder) Exports(exports ...any) *ModuleBuilder
Exports marks providers as exportable to other modules
func (*ModuleBuilder) Imports ¶
func (b *ModuleBuilder) Imports(modules ...Module) *ModuleBuilder
Imports adds modules to be imported
func (*ModuleBuilder) Providers ¶
func (b *ModuleBuilder) Providers(providers ...Provider) *ModuleBuilder
Providers adds providers to the module
type ModuleCompiler ¶
type ModuleCompiler struct {
// contains filtered or unexported fields
}
ModuleCompiler compiles modules into executable units
func NewModuleCompiler ¶
func NewModuleCompiler() *ModuleCompiler
NewModuleCompiler creates a new module compiler
func (*ModuleCompiler) Compile ¶
func (mc *ModuleCompiler) Compile(module Module) (*ModuleRef, error)
Compile compiles a module and its dependencies
func (*ModuleCompiler) Get ¶
func (mc *ModuleCompiler) Get(module Module) (*ModuleRef, bool)
Get retrieves a compiled module by type
func (*ModuleCompiler) GetAll ¶
func (mc *ModuleCompiler) GetAll() []*ModuleRef
GetAll returns all compiled modules
type ModuleMetadata ¶
type ModuleMetadata struct {
// contains filtered or unexported fields
}
ModuleMetadata stores module metadata
type ModuleRef ¶
type ModuleRef struct {
// contains filtered or unexported fields
}
ModuleRef represents a compiled module instance
func (*ModuleRef) ExportProvider ¶
ExportProvider marks a provider as exported
func (*ModuleRef) GetControllers ¶
func (mr *ModuleRef) GetControllers() []ControllerRef
GetControllers returns all controllers in the module
func (*ModuleRef) GetProvider ¶
GetProvider retrieves a provider from the module
func (*ModuleRef) RegisterController ¶
RegisterController registers a controller in the module
type NestApplication ¶
type NestApplication struct {
// contains filtered or unexported fields
}
NestApplication is the main application instance
func (*NestApplication) Close ¶
func (app *NestApplication) Close() error
Close gracefully shuts down the application
func (*NestApplication) GetMetadata ¶
func (app *NestApplication) GetMetadata() *MetadataStorage
GetMetadata returns the metadata storage
func (*NestApplication) GetRouter ¶
func (app *NestApplication) GetRouter() *Router
GetRouter returns the application router
func (*NestApplication) Listen ¶
func (app *NestApplication) Listen(addr string) error
Listen starts the HTTP server
type NestFactory ¶
type NestFactory struct{}
NestFactory creates NestJS-style applications
func (NestFactory) Create ¶
func (f NestFactory) Create(rootModule Module, opts ...ApplicationOption) *NestApplication
Create creates a new NestApplication with the root module
type OnApplicationBootstrap ¶
OnApplicationBootstrap lifecycle hook called when application starts
type OnApplicationShutdown ¶
OnApplicationShutdown lifecycle hook called before application stops
type OnModuleDestroy ¶
OnModuleDestroy lifecycle hook called when module is destroyed
type OnModuleInit ¶
OnModuleInit lifecycle hook called when module is initialized
type ParameterMetadata ¶
type ParameterMetadata struct {
Name string
Type string // "query", "path", "body", "header"
Required bool
Description string
Schema any
}
ParameterMetadata stores parameter-specific metadata
type RouteDefinition ¶
type RouteDefinition struct {
Method string
Path string
Handler HandlerFunc
Middlewares []MiddlewareFunc
}
RouteDefinition defines a single route with its configuration
type RouteMetadata ¶
type RouteMetadata struct {
Method string
Path string
Summary string
Description string
Tags []string
Deprecated bool
}
RouteMetadata stores route-specific metadata
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router manages HTTP routes
func (*Router) Delete ¶
func (r *Router) Delete(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Delete registers a DELETE route
func (*Router) Get ¶
func (r *Router) Get(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Get registers a GET route
func (*Router) Head ¶
func (r *Router) Head(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Head registers a HEAD route
func (*Router) Options ¶
func (r *Router) Options(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Options registers an OPTIONS route
func (*Router) Patch ¶
func (r *Router) Patch(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Patch registers a PATCH route
func (*Router) Post ¶
func (r *Router) Post(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Post registers a POST route
func (*Router) Put ¶
func (r *Router) Put(path string, handler HandlerFunc, middlewares ...MiddlewareFunc)
Put registers a PUT route
func (*Router) Register ¶
func (r *Router) Register(route RouteDefinition)
Register registers a route
func (*Router) ServeHTTP ¶
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements http.Handler
func (*Router) Use ¶
func (r *Router) Use(middleware MiddlewareFunc)
Use applies middleware globally