framework

package module
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2021 License: MIT Imports: 11 Imported by: 2

README

A golang framework for web artisan.

Components

TODO

  • Authentication (component incomplete)
  • Message queue (component)
  • Filesystem (component)
  • Logging (component)
  • Database (component, using gorm for now, waiting generics)
  • CLI application
  • Global service container, copy for request lifetime

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppConfigName = "app"

AppConfigName: default app config name

View Source
var ConfigExt = ".yaml"

ConfigExt: default config extension

Functions

This section is empty.

Types

type App added in v0.0.5

type App struct {
	// contains filtered or unexported fields
}

App: framework application

func NewApp added in v0.0.5

func NewApp(configFs fs.FS) *App

NewApp: new application instance

func (*App) Bind added in v0.0.7

func (app *App) Bind(bf BindFunc)

Bind instance to global ioc-container

func (*App) Bootstrap added in v0.0.5

func (app *App) Bootstrap() error

Bootstrap application, will call before app run

func (*App) Configure added in v0.0.5

func (app *App) Configure(name string, value interface{}) *App

Configure: load config instance and add to config service

func (*App) ConfigureFS added in v0.0.7

func (app *App) ConfigureFS(fs fs.FS, name string, value interface{}) *App

ConfigureFS: load config from filesystem

func (*App) Container added in v0.0.7

func (app *App) Container() container.Interface

Container get global ioc-container

func (*App) Daemon added in v0.0.7

func (app *App) Daemon(f DaemonFn) *App

Daemon run function, start daemon service before http service started

func (*App) Defer added in v0.0.7

func (app *App) Defer(f func()) *App

Defer run function, run after server shutdown

func (*App) GetConfig added in v0.0.5

func (app *App) GetConfig() Config

GetConfig: get app config instance

func (*App) GetEnv added in v0.0.7

func (app *App) GetEnv() string

GetEnv: get app env

func (*App) Register added in v0.0.5

func (app *App) Register(service Service) *App

Register application service provider service

func (*App) RegisterRoutes added in v0.0.7

func (app *App) RegisterRoutes(rr RouterRegister) *App

RegisterRoutes: register routes of http service

func (*App) Run added in v0.0.5

func (app *App) Run() error

Run application service

func (*App) RunDaemons added in v0.0.7

func (app *App) RunDaemons(wg *sync.WaitGroup, daemon ...bool)

RunDaemons, run background services

func (*App) RunDefers added in v0.0.7

func (app *App) RunDefers()

func (*App) Services added in v0.0.7

func (app *App) Services() []Service

type BindFunc added in v0.0.7

type BindFunc func(ioc container.Interface)

type Config added in v0.0.5

type Config struct {
	Env      string `yaml:"env" env:"APP_ENV" default:"production"`
	Debug    bool   `yaml:"debug" env:"APP_DEBUG" default:"false"`
	Locale   string `yaml:"locale" env:"APP_LOCALE" default:"en"`
	Url      string `yaml:"url" env:"APP_URL" default:"http://localhost"`
	Timezone string `yaml:"timezone" env:"APP_TIMEZONE" default:""`
	Key      string `yaml:"key" env:"APP_KEY" default:"somerandomkey!!!"`
}

Config of application

var AppConfig Config

AppConfig global var

type ConfigService added in v0.0.5

type ConfigService struct {
	// contains filtered or unexported fields
}

ConfigService of application

func (*ConfigService) Add added in v0.0.5

func (cs *ConfigService) Add(name string, config interface{}) *ConfigService

Add config instance to service

func (*ConfigService) Register added in v0.0.5

func (cs *ConfigService) Register(app *App) error

Register config service when app starting

type DaemonFn added in v0.0.7

type DaemonFn func(exit chan struct{})

type RouterRegister added in v0.0.7

type RouterRegister func(rw *router.Wrapper)

type Service added in v0.0.5

type Service interface {
	//Register service when app starting, before http server start
	// you can configure service, prepare global vars etc.
	// running at main goroutine
	Register(app *App) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL