app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	*Options
	Gin               *gin.Engine
	Config            *config.Config
	Logger            *logrus.Logger
	Middlewares       []gin.HandlerFunc
	Components        []string
	ComponentMounters []ComponentMount
	RouterRegisters   []func(r *gin.Engine)
	Once              sync.Once
}

App struct

func NewApp

func NewApp(opts ...Option) *App

NewApp return an pointer to App

func (*App) Bootstrap

func (app *App) Bootstrap() *App

Bootstrap use for boot core components

func (*App) BootstrapWith

func (app *App) BootstrapWith(mounters ...ComponentMount) *App

BootstrapWith use for register component

func (*App) RegisterRouter

func (app *App) RegisterRouter(f ...func(r *gin.Engine)) *App

RegisterRouter use for register router

func (*App) Run

func (app *App) Run() (err error)

Run use for run application

func (*App) SetGin

func (app *App) SetGin(gin *gin.Engine) *App

SetGin for inject gin Engin into App

func (*App) Use

func (app *App) Use(middlewares ...gin.HandlerFunc) *App

Use for add global middleware

func (*App) WaitGracefulExit

func (app *App) WaitGracefulExit(srv *http.Server)

WaitGracefulExit graceful exit

type ComponentMount

type ComponentMount func(*App) error

ComponentMount use for mount component interface

type Option

type Option func(*Options)

Option use for inject option

type Options

type Options struct {
	Name          string
	Addr          string
	RunMode       string
	CfgCenterAddr string
	CfgCenterPath string
	ShowBanner    bool
}

Options struct define app options

Jump to

Keyboard shortcuts

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