momo

package module
v1.1.20 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

README

momo

介绍

go语言写的实用类库

使用说明

func main() { // 定义命令行参数 mode := flag.String("mode", "release", "运行模式:debug, release, test") acl := flag.Bool("acl", true, "是否启用访问控制:true,false") acs := flag.Bool("acs", true, "是否启用访问统计:true,false") port := flag.Int("port", 6001, "主程序运行端口") prome := flag.Int("prome_port", 6011, "prometheus运行端口") static := flag.String("static", "admin", "静态目录") flag.Parse()

// 初始化基本路由
r := momo.NewRouterBuilder().WithMode(*mode).WithAcl(*acl).WithAcs(*acs).WithPromePort(*prome).WithLog(true).Build()
r.Static("/view", "view")
r.Static("/admin", *static)
fmt.Printf(" - using static:  %v\n", *static)
fmt.Printf(" - using port:  %v\n", *port)

// 注册自定义路由分组
// genAdapter := igin.NewGinRouterAdapter(r.Engine).Group("/api/gen")
// genCtl.DataSourceRouter(genAdapter)
r.Run(fmt.Sprintf("0.0.0.0:%d", *port))

// 自定义rbac数据库
// db := dao.RbacDb
// db := rbacService.RbacDb
// userRepo := rbac.NewGormUserRepo(db, &model.UserEntity{})
// roleRepo := rbac.NewGormRoleRepo(db, &model.RoleEntity{})
// permitRepo := rbac.NewGormPermitRepo(db, &model.MenuEntity{})
// rb.config.Service = rbac.NewRBACService(userRepo, roleRepo, permitRepo, rb.config.SecretKey)

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddle added in v1.0.2

func CORSMiddle() igin.HandlerFunc

func ConfRouter added in v1.0.2

func ConfRouter(router igin.IRouterGroup)

func GenRouter added in v1.0.2

func GenRouter(router igin.IRouterGroup)

func JobRouter added in v1.0.2

func JobRouter(router igin.IRouterGroup)

func LogRouter added in v1.0.2

func LogRouter(router igin.IRouterGroup)

func MinRouter added in v1.0.2

func MinRouter(port int, group, secretKey string, service rbac.IRBACService) igin.Engine

func RbacRouter added in v1.0.2

func RbacRouter(router igin.IRouterGroup)

func SrvRouter added in v1.0.2

func SrvRouter(router igin.IRouterGroup)

func SysMiddle added in v1.0.2

func SysMiddle(router igin.Engine, maxCores int)

Types

type RouterBuilder added in v1.0.2

type RouterBuilder interface {
	WithPromePort(port int) RouterBuilder
	WithMode(mode string) RouterBuilder
	WithSecretKey(secretKey string) RouterBuilder
	WithService(service rbac.IRBACService) RouterBuilder
	WithAcl(acl bool) RouterBuilder
	WithAcs(acs bool) RouterBuilder
	WithLog(log bool) RouterBuilder
	Build() igin.Engine
}

func NewRouterBuilder added in v1.0.2

func NewRouterBuilder() RouterBuilder

type RouterConfig added in v1.0.2

type RouterConfig struct {
	Mode      string
	SecretKey string
	Acl       bool
	Acs       bool
	Log       bool
	Service   rbac.IRBACService
	PromePort int
	// contains filtered or unexported fields
}

Directories

Path Synopsis
app
rbac/captcha/assets/bindata/images
Code generated for package images by go-bindata DO NOT EDIT.
Code generated for package images by go-bindata DO NOT EDIT.
rbac/captcha/assets/bindata/tiles
Code generated for package tiles by go-bindata DO NOT EDIT.
Code generated for package tiles by go-bindata DO NOT EDIT.
controllers/base_controller.go
controllers/base_controller.go
service/base_service.go
service/base_service.go
collector
Package collector includes all individual collectors to gather and export system metrics.
Package collector includes all individual collectors to gather and export system metrics.

Jump to

Keyboard shortcuts

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