web

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 11 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CONFIG = Web{
	FileMaxSize:    1024,
	SessionTimeout: 60,
	Cors: Cors{
		AccessOrigin:        "*",
		AccessHeaders:       "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id",
		AccessMethods:       "POST,GET,OPTIONS,DELETE,PUT",
		AccessExposeHeaders: "Content-Length,Access-Control-Allow-Origin,Access-Control-Allow-Headers,Content-Type",
		AccessCredentials:   "true",
	},
	Except: Route{
		Uri:    "",
		Method: "",
	},
	System: System{
		Tls:        false,
		Level:      "debug",
		Addr:       "127.0.0.1:8085",
		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 Initialize added in v1.2.0

func Initialize() error

Initialize initialize

func IsExist added in v1.1.2

func IsExist() bool

IsExist config file is exist

func Recover added in v1.2.0

func Recover() error

Recover

func Remove added in v1.1.2

func Remove() error

Remove remove config file

func SetDefaultAddrAndTimeFormat added in v1.2.15

func SetDefaultAddrAndTimeFormat()

SetDefaultAddrAndTimeFormat

func Start

func Start(wf WebFunc)

Start

func StartTest

func StartTest(wf WebFunc)

StartTest

func ToStaticUrl added in v1.1.2

func ToStaticUrl(uri string) string

ToStaticUrl

Types

type Captcha added in v1.1.2

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

type Cors added in v1.2.15

type Cors struct {
	AccessOrigin        string `mapstructure:"access-origin" json:"burst" access-origin:"access-origin"`
	AccessHeaders       string `mapstructure:"access-headers" json:"access-headers" yaml:"access-headers"`
	AccessMethods       string `mapstructure:"access-methods" json:"access-methods" yaml:"access-methods"`
	AccessExposeHeaders string `mapstructure:"access-expose-headers" json:"access-expose-headers" yaml:"access-expose-headers"`
	AccessCredentials   string `mapstructure:"access-credentials" json:"access-credentials" yaml:"access-credentials"`
}

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:"static-prefix" yaml:"static-prefix"`
	WebPrefix    string `mapstructure:"web-prefix" json:"web-prefix" yaml:"web-prefix"`
	DbType       string `mapstructure:"db-type" json:"db-type" yaml:"db-type"`
	TimeFormat   string `mapstructure:"time-format" json:"time-format" yaml:"time-format"`
}

type Web added in v1.1.2

type Web struct {
	FileMaxSize    int64   `mapstructure:"file-max-size" json:"file-max-size" yaml:"file-max-siz"`
	SessionTimeout int64   `mapstructure:"session-timeout" json:"session-timeout" yaml:"session-timeout"`
	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"`
	Cors           Cors    `mapstructure:"cors" json:"cors" yaml:"cors"`
}

type WebBaseFunc added in v1.1.2

type WebBaseFunc interface {
	AddWebStatic(staticAbsPath, webPrefix string, paths ...string)
	AddUploadStatic(staticAbsPath, webPrefix string)
	InitRouter() error
	Run()
}

type WebFunc

type WebFunc interface {
	WebBaseFunc
}

WebFunc - GetTestClient - GetTestLogin - AddWebStatic - AddUploadStatic - Run

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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