web_iris

package
v1.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 28 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CONFIG = Web{
	MaxSize: 1024,
	Except: Route{
		Uri:    "",
		Method: "",
	},
	System: System{
		Level:        "debug",
		Addr:         "127.0.0.1:8085",
		StaticPrefix: "/upload",
		StaticPath:   "/static/upload",
		WebPrefix:    "/admin",
		WebPath:      "./dist",
		DbType:       "mysql",
		CacheType:    "redis",
		TimeFormat:   "2006-01-02 15:04:05",
	},
	Limit: Limit{
		Disable: true,
		Limit:   0,
		Burst:   5,
	},
	Captcha: Captcha{
		KeyLong:   4,
		ImgWidth:  240,
		ImgHeight: 80,
	},
}
View Source
var ErrAuthDriverEmpty = errors.New("认证驱动初始化失败")

Functions

func InitConfig

func InitConfig() error

InitConfig 初始化配置文件

func InitWeb

func InitWeb()

InitWeb 初始化配置

func IsExist

func IsExist() bool

IsExist 配置文件是否存在

func Remove

func Remove() error

Remove 删除配置文件

Types

type Captcha

type Captcha struct {
	KeyLong   int `mapstructure:"key-long" json:"keyLong" yaml:"key-long"`
	ImgWidth  int `mapstructure:"img-width" json:"imgWidth" yaml:"img-width"`
	ImgHeight int `mapstructure:"img-height" json:"imgHeight" yaml:"img-height"`
}

type Limit

type Limit struct {
	Disable bool    `mapstructure:"disable" json:"disable" yaml:"disable"`
	Limit   float64 `mapstructure:"limit" json:"limit" yaml:"limit"`
	Burst   int     `mapstructure:"burst" json:"burst" yaml:"burst"`
}

type Party

type Party struct {
	Perfix    string
	PartyFunc func(index iris.Party)
}

Party 功能模块 - perfix 模块路由路径 - partyFunc 模块

type Route

type Route struct {
	Uri    string `mapstructure:"uri" json:"uri" yaml:"uri"`
	Method string `mapstructure:"method" json:"method" yaml:"method"`
}

type System

type System struct {
	Level        string `mapstructure:"level" json:"level" yaml:"level"` // debug,release,test
	Addr         string `mapstructure:"addr" json:"addr" yaml:"addr"`
	StaticPrefix string `mapstructure:"static-prefix" json:"staticPrefix" yaml:"static-prefix"`
	StaticPath   string `mapstructure:"static-path" json:"staticPath" yaml:"static-path"`
	WebPrefix    string `mapstructure:"web-prefix" json:"webPPrefix" yaml:"web-prefix"`
	WebPath      string `mapstructure:"web-path" json:"webPath" yaml:"web-path"`
	DbType       string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
	CacheType    string `mapstructure:"cache-type" json:"cacheType" yaml:"cache-type"`
	TimeFormat   string `mapstructure:"time-format" json:"timeFormat" yaml:"time-format"`
}

type Web

type Web struct {
	MaxSize int64   `mapstructure:"max-size" json:"burst" yaml:"max-size"`
	Except  Route   `mapstructure:"except" json:"except" yaml:"except"`
	System  System  `mapstructure:"system" json:"system" yaml:"system"`
	Limit   Limit   `mapstructure:"limit" json:"limit" yaml:"limit"`
	Captcha Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
}

type WebServer

type WebServer struct {
	// contains filtered or unexported fields
}

WebServer web服务 - app iris application - idleConnsClosed - addr 服务访问地址 - timeFormat 时间格式 - staticPrefix 静态文件访问地址前缀 - staticPath 静态文件地址 - webPath 前端文件地址

func Init

func Init() *WebServer

Init 初始化web服务 先初始化基础服务 config , zap , database , casbin e.g.

func (*WebServer) AddModule

func (ws *WebServer) AddModule(parties ...Party)

AddModule 添加模块

func (*WebServer) AddStatic

func (ws *WebServer) AddStatic(requestPath string, fsOrDir interface{}, opts ...iris.DirOptions)

AddStatic 添加静态文件

func (*WebServer) AddUploadStatic

func (ws *WebServer) AddUploadStatic()

AddUploadStatic 添加上传文件访问地址

func (*WebServer) AddWebStatic

func (ws *WebServer) AddWebStatic()

AddWebStatic 添加前端访问地址

func (*WebServer) GetSources

func (ws *WebServer) GetSources() ([]map[string]string, []map[string]string)

GetSources 获取系统路由 - PermRoutes 权鉴路由 - NoPermRoutes 公共路由

func (*WebServer) GetTestClient

func (ws *WebServer) GetTestClient(t *testing.T) *httptest.Client

GetTestClient 获取测试验证客户端

func (*WebServer) GetTestLogin

func (ws *WebServer) GetTestLogin(t *testing.T, url string, res httptest.Responses, datas ...interface{}) *httptest.Client

GetTestLogin 测试登录web服务

func (*WebServer) InitDriver

func (ws *WebServer) InitDriver() error

InitDriver 初始化认证

func (*WebServer) InitRouter

func (ws *WebServer) InitRouter() error

InitRouter 初始化模块路由

func (*WebServer) Run

func (ws *WebServer) Run()

Run 启动web服务

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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