Global
function
Returns:
Show/Hide Function
Body
{ return global }
Registry
struct
Fields:
- ServiceInit (map[string]ServiceInit)
- RepoInit (map[string]RepoInit)
- HandlerInit (map[string]HandlerInit)
- MiddlewareInit (map[string]MiddlewareInit)
- ModelProviders ([]ModelProvider)
- RouteProviders ([]RouteProvider)
- mu (sync.RWMutex)
New
function
Returns:
Show/Hide Function
Body
{
return &Registry{
ServiceInit: map[string]ServiceInit{},
RepoInit: map[string]RepoInit{},
HandlerInit: map[string]HandlerInit{},
MiddlewareInit: map[string]MiddlewareInit{},
}
}
RegisterService
function
Parameters:
- name string
- fn ServiceInit
References:
-
ServiceInit
(v1/registry)
Show/Hide Function
Body
{
global.mu.Lock()
defer global.mu.Unlock()
global.ServiceInit[name] = fn
}
RegisterRepository
function
Parameters:
References:
Show/Hide Function
Body
{
global.mu.Lock()
defer global.mu.Unlock()
global.RepoInit[name] = fn
}
RegisterHandler
function
Parameters:
- name string
- fn HandlerInit
References:
-
HandlerInit
(v1/registry)
Show/Hide Function
Body
{
global.mu.Lock()
defer global.mu.Unlock()
global.HandlerInit[name] = fn
}
RegisterMiddleware
function
Parameters:
- name string
- fn MiddlewareInit
References:
-
MiddlewareInit
(v1/registry)
Show/Hide Function
Body
{
global.mu.Lock()
defer global.mu.Unlock()
global.MiddlewareInit[name] = fn
}
RegisterModels
function
Parameters:
References:
-
ModelProvider
(v1/registry)
Show/Hide Function
Body
{
global.mu.Lock()
defer global.mu.Unlock()
global.ModelProviders = append(global.ModelProviders, fn)
}
RegisterRoutes
function
Parameters:
References:
-
RouteProvider
(v1/registry)
Show/Hide Function
Body
{
global.mu.Lock()
defer global.mu.Unlock()
global.RouteProviders = append(global.RouteProviders, fn)
}
ServiceInit
type
Type Definition:
func(repos map[string]any) any
RepoInit
type
Type Definition:
func(deps map[string]any) any
HandlerInit
type
Type Definition:
func(services map[string]any) any
MiddlewareInit
type
Type Definition:
func(services map[string]any, sessionDur time.Duration) any
ModelProvider
type
Type Definition:
func() []any
RouteProvider
type
Type Definition:
func() []Route
Route
struct
Fields:
- Method (string)
- Path (string)
- HandlerName (string)
- Middleware ([]string)
- Permissions ([]string)
- Meta (map[string]any)
sync import
Import example:
import "sync"
time import
Import example:
import "time"