web

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuroraMultipartFile = "AuroraMultipartFile" //文件解析
	AuroraRequest       = "AuroraRequest"       //go 原生请求
	AuroraResponse      = "AuroraResponse"      //go 原生响应
	AuroraValues        = "AuroraValues"
)

Variables

This section is empty.

Functions

func ErrRecover added in v1.3.7

func ErrRecover(w http.ResponseWriter)

ErrRecover 全局错误 panic 处理

func View

func View(fullPath, relative string, static embed.FS, rew http.ResponseWriter, data Context)

Types

type Component

type Component map[string]any

Component 命名组件

type Config

type Config interface {
	SetConfigFile(string)
	SetConfigType(string)
	ReadConfig(io.Reader) error
	Set(string, interface{})
	SetDefault(string, interface{})
	GetStringMapString(string) map[string]string
	Get(string) interface{}
	GetStringSlice(string) []string
	GetStringMap(string) map[string]interface{}
	GetString(string) string
	GetStringMapStringSlice(string) map[string][]string
}

type ConfigCenter

type ConfigCenter struct {
	*viper.Viper
	*sync.RWMutex
}

ConfigCenter 配置中心 的读写锁主要用来解决分布式配置的动态刷新配置,和以后存在的并发读取配置和修改, 对于修改配置数据库连接信息或者需要重新初始化的配置项这些无法起到同步更新的效果只能保持配置信息是最新的(需要重新初始化的配置建议重启服务), 对被配置的使用实例没有并发安全的效果。

func (*ConfigCenter) Get

func (c *ConfigCenter) Get(key string) interface{}

func (*ConfigCenter) GetString

func (c *ConfigCenter) GetString(key string) string

func (*ConfigCenter) GetStringMap

func (c *ConfigCenter) GetStringMap(key string) map[string]interface{}

func (*ConfigCenter) GetStringMapString

func (c *ConfigCenter) GetStringMapString(key string) map[string]string

func (*ConfigCenter) GetStringMapStringSlice

func (c *ConfigCenter) GetStringMapStringSlice(key string) map[string][]string

func (*ConfigCenter) GetStringSlice

func (c *ConfigCenter) GetStringSlice(key string) []string

func (*ConfigCenter) ReadConfig

func (c *ConfigCenter) ReadConfig(in io.Reader) error

func (*ConfigCenter) ReadInConfig

func (c *ConfigCenter) ReadInConfig() error

func (*ConfigCenter) Set

func (c *ConfigCenter) Set(key string, value interface{})

func (*ConfigCenter) SetConfigFile

func (c *ConfigCenter) SetConfigFile(in string)

func (*ConfigCenter) SetConfigType

func (c *ConfigCenter) SetConfigType(in string)

func (*ConfigCenter) SetDefault

func (c *ConfigCenter) SetDefault(key string, value interface{})

func (*ConfigCenter) WatchRemoteConfig

func (c *ConfigCenter) WatchRemoteConfig() error

type Constructor

type Constructor func() any

Constructor 用于加载 匿名组件的构造器类型 Aurora 会执行这个函数 并把得到的变量加载到容器中

type Context

type Context map[string]interface{}

Context 上下文参数,主要用于在业务之间传递 数据使用 上下文参数中获取请求参数需要依赖于传递的参数名称 Ctx 不是线程安全的,在请求中出现多线程操作需要使用锁来保证安全性

func (Context) Clear

func (ctx Context) Clear()

func (Context) MultipartFile

func (ctx Context) MultipartFile() *MultipartFile

MultipartFile 获取POST文件上传

func (Context) Request

func (ctx Context) Request() *http.Request

Request 返回元素 Request

func (Context) Response

func (ctx Context) Response() http.ResponseWriter

Response 返回元素 ResponseWriter

func (Context) Return

func (ctx Context) Return(value ...interface{})

Return 设置中断处理,多次调用会覆盖之前设置的值

type ControlInfo

type ControlInfo struct {
	Path       string
	Control    any
	Middleware []Middleware
}

ControlInfo 用于存储在服务器启动之前注册的接口信息,需要在加载完配置项之后进行统一注册

type Formatter

type Formatter struct {
	*logrus.TextFormatter
}

func (*Formatter) Format

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error)

type Log

type Log interface {
	Info(...interface{})
	Error(...interface{})
	Debug(...interface{})
	Panic(...interface{})
	Warn(...interface{})
}

Log 自定义Log需要实现的借口

type Middleware

type Middleware func(ctx Context) bool

Middleware 中间件类型

type MultipartFile

type MultipartFile struct {
	File map[string][]*multipart.FileHeader
}

func (*MultipartFile) SaveUploadedFile

func (m *MultipartFile) SaveUploadedFile(file *multipart.FileHeader, dst string) error

SaveUploadedFile 保存文件

type Recover added in v1.3.7

type Recover func(w http.ResponseWriter)

Recover 用于处理服务器中出现的 panic 消息自定义

type Variate

type Variate func(ctx Context) any

Variate 用于配置web系统变量函数

type Verify added in v1.3.3

type Verify func(value any) error

type ViewHandle

type ViewHandle func(string, string, embed.FS, http.ResponseWriter, Context)

ViewHandle 是整个服务器对视图渲染的核心函数,开发者实现改接口对需要展示的页面进行自定义处理

Jump to

Keyboard shortcuts

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