application

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Env = &config{}

Functions

func GetConfReader added in v2.1.5

func GetConfReader() *viper.Viper

GetConfReader Get config reader of the application

func LoadApplicationConfigFile

func LoadApplicationConfigFile(options []viper.Option) *viper.Viper

LoadApplicationConfigFile load the application configuration file

Types

type App

type App struct {
	Interceptors []mvc.MethodInterceptor
	// contains filtered or unexported fields
}

App application instance

func Default

func Default(confReaderOptions ...viper.Option) *App

Default Create a default application with log printing, exception interception, and cross-domain middleware

func New

func New(confReaderOptions []viper.Option, middlewares ...gin.HandlerFunc) *App

New Create a clean application, you can add some gin middlewares to the engine

func (*App) Banner added in v2.1.5

func (a *App) Banner(banner string) *App

Banner Sets the project startup banner

func (*App) ExitDelay added in v2.2.0

func (a *App) ExitDelay(time time.Duration) *App

ExitDelay Graceful exit time(default 3s), when reached to shut down the server and trigger PostStop().

func (*App) Interceptor added in v2.2.2

func (a *App) Interceptor(interceptor ...mvc.MethodInterceptor) *App

Interceptor Add a global interceptor

func (*App) PostStop added in v2.2.0

func (a *App) PostStop(f func()) *App

PostStop Events after the application has stopped can perform other closing operations here

func (*App) PreApply added in v2.2.0

func (a *App) PreApply(f func()) *App

PreApply triggered before mvc starts, Before the project starts. This is where you can provide basic services, such as set beans. Of course, you can also perform logic here that doesn't require obtaining beans.

func (*App) PreStart added in v2.2.0

func (a *App) PreStart(f func()) *App

PreStart The last event before the project starts, dependency injection is all finished and ready to run. You can execute any logic here.

func (*App) PreStop added in v2.2.0

func (a *App) PreStop(f func()) *App

PreStop The event before the application stops can be performed here to close some resources

func (*App) ReadConfig

func (a *App) ReadConfig(v interface{}) *App

ReadConfig Read configuration v config struct pointer

func (*App) Run

func (a *App) Run(interceptors ...mvc.MethodInterceptor)

Run the main program entry interceptors: link{mvc.MethodInterceptor}

Jump to

Keyboard shortcuts

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