Global function

Returns:

  • *Registry
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:

  • *Registry
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:

Show/Hide Function Body
{
	global.mu.Lock()
	defer global.mu.Unlock()
	global.ServiceInit[name] = fn
}

RegisterRepository function

Parameters:

  • name string
  • fn RepoInit

References:

Show/Hide Function Body
{
	global.mu.Lock()
	defer global.mu.Unlock()
	global.RepoInit[name] = fn
}

RegisterHandler function

Parameters:

  • name string
  • fn HandlerInit

References:

Show/Hide Function Body
{
	global.mu.Lock()
	defer global.mu.Unlock()
	global.HandlerInit[name] = fn
}

RegisterMiddleware function

Parameters:

  • name string
  • fn MiddlewareInit

References:

Show/Hide Function Body
{
	global.mu.Lock()
	defer global.mu.Unlock()
	global.MiddlewareInit[name] = fn
}

RegisterModels function

Parameters:

  • fn ModelProvider

References:

Show/Hide Function Body
{
	global.mu.Lock()
	defer global.mu.Unlock()
	global.ModelProviders = append(global.ModelProviders, fn)
}

RegisterRoutes function

Parameters:

  • fn RouteProvider

References:

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"