goof

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonToJson

func JsonToJson[Payload any, Response any](cb PipelineHandler[Payload, Response]) gin.HandlerFunc

func ToJson

func ToJson[Response any](cb ResponseHandler[Response]) gin.HandlerFunc

Types

type BaseController

type BaseController struct{}

func (*BaseController) Init

func (c *BaseController) Init(config ControllerConfig) (err error)

func (*BaseController) MountHTTP

func (c *BaseController) MountHTTP(router gin.IRouter) (err error)

type Controller

type Controller interface {
	Init(config ControllerConfig) (err error)
	MountHTTP(router gin.IRouter) (err error)
}

type ControllerConfig

type ControllerConfig struct {
	Addr string
	Host string
}

type ControllersModule

type ControllersModule interface {
	Controllers(db *sqlx.DB) []Controller
}

type HttpConfig

type HttpConfig struct {
	Addr string
	Host string
	SSL  struct {
		Enabled  bool
		CertFile string
		KeyFile  string
	}
}

type MigrationsModule

type MigrationsModule interface {
	Migrations() []migrate.Migration
}

type Module

type Module interface {
	Id() string
	PreInit(api ModuleApi, config any) (err error)
	Init(api ModuleApi, config any) (err error)
	PostInit(api ModuleApi, config any) (err error)
	Close() (err error)
}

type ModuleApi

type ModuleApi interface {
	AddController(controllers ...Controller)
	AddMigration(migrations ...migrate.Migration)
	GetDB() (*sqlx.DB, error)
	GetSessionStore() (sessions.Store, error)
}

type ModuleBase

type ModuleBase struct{}

func (*ModuleBase) Close

func (m *ModuleBase) Close() (err error)

func (*ModuleBase) Init

func (m *ModuleBase) Init(api ModuleApi, config interface{}) (err error)

func (*ModuleBase) PostInit

func (m *ModuleBase) PostInit(api ModuleApi, config interface{}) (err error)

func (*ModuleBase) PreInit

func (m *ModuleBase) PreInit(api ModuleApi, config interface{}) (err error)

type PipelineHandler

type PipelineHandler[Payload any, Response any] func(*gin.Context, Payload) (Response, int, error)

type RequestHandler

type RequestHandler[Payload any] func(*gin.Context, Payload) (int, error)

type ResponseHandler

type ResponseHandler[Response any] func(*gin.Context) (Response, int, error)

type RootConfig

type RootConfig struct {
	Production bool
	DB         driver.Config
	Http       HttpConfig
	Log        log.Config
}

type RootModule

type RootModule struct {
	Config RootConfig
	// contains filtered or unexported fields
}

func (*RootModule) Add

func (r *RootModule) Add(modules ...Module)

Add a module to the root module. Modules are initialized in the order they are added.

func (*RootModule) AddMiddleware

func (r *RootModule) AddMiddleware(middleware ...gin.HandlerFunc)

Add a middleware to every route in under the root module. Middlewares are applied in the order they are added.

func (*RootModule) Init

func (r *RootModule) Init() (err error)

Init the root module. All modules should be added before calling Init.

func (*RootModule) Run

func (r *RootModule) Run() (err error)

Start the server. This will initialize the server if it has not already been initialized.

Jump to

Keyboard shortcuts

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