framework

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 7 Imported by: 2

README

a modern web framework

Working on it...

TODO

  • Authentication (component)
  • Filesystem (component)
  • Database (component, using gorm for now)
  • CLI application

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppConfig = "app"

AppConfig: 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) Bootstrap added in v0.0.5

func (app *App) Bootstrap() (*http.Server, 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) GetConfig added in v0.0.5

func (app *App) GetConfig() Config

GetConfig: get app config instance

func (*App) Register added in v0.0.5

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

Register application service service

func (*App) Run added in v0.0.5

func (app *App) Run(at string, register http.RouterRegister) error

Run application service

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"`
}

Config of application

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) Lifetime added in v0.0.5

func (cs *ConfigService) Lifetime(container container.Interface, request contracts.RequestContract)

Lifetime container callback register config instance to request IoC-Container

func (*ConfigService) Register added in v0.0.5

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

Register config service when app starting

type Service added in v0.0.5

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

	//Lifetime container callback
	// usually register request lifetime instance to IoC-Container (per-request unique)
	// this function will run before every request
	Lifetime(ioc container.Interface, request contracts.RequestContract)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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