web

package
v1.1.1-alpha17 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: Apache-2.0 Imports: 12 Imported by: 11

Documentation

Index

Constants

View Source
const (
	AdminAuthorityId   uint = 1 // 管理员用户
	TenancyAuthorityId uint = 2 // 商户用户
	LiteAuthorityId    uint = 3 // 小程序用户
	DeviceAuthorityId  uint = 4 // 床旁设备用户
)

Variables

View Source
var CONFIG = Web{
	MaxSize: 1024,
	Except: Route{
		Uri:    "",
		Method: "",
	},
	System: System{
		Tls:           false,
		Level:         "debug",
		Addr:          "127.0.0.1:8085",
		StaticPrefix:  "",
		StaticAbsPath: "",
		WebPrefix:     "",
		DbType:        "mysql",
		TimeFormat:    "2006-01-02 15:04:05",
	},
	Limit: Limit{
		Disable: true,
		Limit:   0,
		Burst:   5,
	},
	Captcha: Captcha{
		KeyLong:   4,
		ImgWidth:  240,
		ImgHeight: 80,
	},
}

Functions

func InitWeb added in v1.1.2

func InitWeb()

InitWeb 初始化配置

func IsExist added in v1.1.2

func IsExist() bool

IsExist 配置文件是否存在

func Remove added in v1.1.2

func Remove() error

Remove 删除配置文件

func Start

func Start(wf WebFunc)

Start 启动 web 服务

func StartTest

func StartTest(wf WebFunc)

StartTest 启动 web 服务

func ToStaticUrl added in v1.1.2

func ToStaticUrl(uri string) string

ToStaticUrl 静态地址url

func Verfiy added in v1.1.2

func Verfiy()

Verfiy

Types

type Captcha added in v1.1.2

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 added in v1.1.2

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 Route added in v1.1.2

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

type System added in v1.1.2

type System struct {
	Tls           bool   `mapstructure:"tls" json:"tls" yaml:"tls"`       // debug,release,test
	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"`
	StaticAbsPath string `mapstructure:"static-abs-path" json:"staticAbsPath" yaml:"static-abs-path"`
	WebPrefix     string `mapstructure:"web-prefix" json:"webPrefix" yaml:"web-prefix"`
	DbType        string `mapstructure:"db-type" json:"dbType" yaml:"db-type"`
	TimeFormat    string `mapstructure:"time-format" json:"timeFormat" yaml:"time-format"`
}

type Web added in v1.1.2

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 WebBaseFunc added in v1.1.2

type WebBaseFunc interface {
	AddWebStatic()
	AddUploadStatic()
	InitRouter() error
	Run()
}

type WebFunc

type WebFunc interface {
	WebBaseFunc
	WebTestFunc
}

WebFunc 框架服务接口 - GetTestClient 测试客户端 - GetTestLogin 测试登录 - AddWebStatic 添加静态页面 - AddUploadStatic 上传文件路径 - Run 启动

type WebTestFunc added in v1.1.2

type WebTestFunc interface {
	GetTestClient(t *testing.T) *httptest.Client
	GetTestLogin(t *testing.T, url string, res httptest.Responses, datas ...interface{}) *httptest.Client
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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