aurora

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 26 Imported by: 1

README

Aurora Web Framework | Engilsh

Stars Go Version Go Package Go Version Go Report Card License

Aurora 是用 Go(Golang) 编写的 Web 框架 ,将是 Golang 自诞生以来最好用的 Web 开发生产工具。路由处理灵活,集中式依赖管理,让项目代码结构更加优雅,专注于业务编码。

go version

go1.18+

快速开始

package main

import "github.com/aurora-go/aurora"

func main() {
	//创建 实例
	a := aurora.NewAurora()
	//注册接口
	a.Get("/", func() {
		a.Info("hello web")
	})
	//启动服务器
	aurora.Run(a)
}

document

document

about the author

作者: Awen

联系: zhiwen_der@qq.com

thanks

该框架参考了,HttpRouter 的字典树 方式来构建路由信息

感谢 JetBrains 支持了该开源项目, 并提供了一年开发工具的支持

该项目签署了Apache授权许可,详情请参阅 LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run added in v0.3.8

func Run(app Application) error

func Use

func Use(app Application, components ...Component)

Use 提供一个全局的注册器,把参数 components 加载到 Aurora实例中

Types

type Application added in v0.3.8

type Application interface {
	Use(...interface{})
	Run() error
}

type ArgsAnalysisError added in v0.3.1

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

ArgsAnalysisError 参数解析错误

func (ArgsAnalysisError) Error added in v0.3.1

func (a ArgsAnalysisError) Error() string

type Aurora

type Aurora struct {
	// 日志
	Log
	// 文件上传大小配置
	MaxMultipartMemory int64
	// contains filtered or unexported fields
}

func NewAurora added in v0.4.5

func NewAurora(option ...Option) *Aurora

func (*Aurora) Catch added in v0.3.1

func (a *Aurora) Catch(err Error)

func (*Aurora) Delete added in v0.3.1

func (a *Aurora) Delete(url string, control Controller, middleware ...Middleware)

Delete 请求

func (*Aurora) Get added in v0.3.1

func (a *Aurora) Get(url string, control Controller, middleware ...Middleware)

Get 请求

func (*Aurora) GetConfig added in v0.3.3

func (a *Aurora) GetConfig() Config

GetConfig 获取 Aurora 配置实例 对配置文件内容的读取都是协程安全的

func (*Aurora) Group

func (a *Aurora) Group(url string, middleware ...Middleware) *Group

Group 路由分组 必须以 “/” 开头分组 Group 和 Aurora 都有 相同的 http 方法注册

func (*Aurora) Head added in v0.3.1

func (a *Aurora) Head(url string, control Controller, middleware ...Middleware)

Head 请求

func (*Aurora) Post added in v0.3.1

func (a *Aurora) Post(url string, control Controller, middleware ...Middleware)

Post 请求

func (*Aurora) Put added in v0.3.1

func (a *Aurora) Put(url string, control Controller, middleware ...Middleware)

Put 请求

func (*Aurora) Run added in v0.3.8

func (a *Aurora) Run() error

Run 启动服务器

func (*Aurora) ServeHTTP

func (a *Aurora) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP 一切的开始

func (*Aurora) Url added in v0.4.8

func (a *Aurora) Url(url string, control Controller, middleware ...Middleware)

Url 结构体专属 注册器

func (*Aurora) Use

func (a *Aurora) Use(Configuration ...interface{})

Use 使用组件,把组件加载成为对应的配置

type Component added in v0.3.3

type Component map[string]interface{}

Component 组件加载类型

type Config added in v0.4.9

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 added in v0.3.9

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 added in v0.3.9

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

type ContentType added in v0.3.8

type ContentType map[string]string

ContentType 定义一个静态资源头类型

type Controller added in v0.3.1

type Controller = interface{}

type Ctx added in v0.3.1

type Ctx map[string]interface{}

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

func (Ctx) AddHeader added in v0.3.1

func (c Ctx) AddHeader(name, value string)

AddHeader 添加一个头

func (Ctx) Clear added in v0.3.3

func (c Ctx) Clear()

func (Ctx) DelHeader added in v0.3.1

func (c Ctx) DelHeader(name string)

DelHeader 删除一个指定的name 的头

func (Ctx) FormFile added in v0.3.9

func (c Ctx) FormFile(name string) (*multipart.FileHeader, error)

FormFile 获取文件

func (Ctx) GetHeader added in v0.3.1

func (c Ctx) GetHeader(name string) string

GetHeader 根据 name 查找一个

func (Ctx) GetPostFormArray added in v0.3.9

func (c Ctx) GetPostFormArray(key string) ([]string, bool)

func (Ctx) GetPostFormMap added in v0.3.9

func (c Ctx) GetPostFormMap(key string) (map[string]string, bool)

func (Ctx) GetQuery added in v0.3.9

func (c Ctx) GetQuery(key string) (string, bool)

func (Ctx) GetQueryArray added in v0.3.9

func (c Ctx) GetQueryArray(key string) ([]string, bool)

func (Ctx) GetQueryMap added in v0.3.9

func (c Ctx) GetQueryMap(key string) (map[string]string, bool)

func (Ctx) MultipartForm added in v0.3.9

func (c Ctx) MultipartForm() (*multipart.Form, error)

func (Ctx) PostFormMap added in v0.3.9

func (c Ctx) PostFormMap(key string) map[string]string

func (Ctx) Query added in v0.3.9

func (c Ctx) Query(key string) string

func (Ctx) QueryMap added in v0.3.9

func (c Ctx) QueryMap(key string) map[string]string

func (Ctx) Ref added in v0.3.9

func (c Ctx) Ref(ref string) interface{}

Ref 获取容器中的依赖项

func (Ctx) Request added in v0.3.1

func (c Ctx) Request() *http.Request

Request 返回元素 Request

func (Ctx) Response added in v0.3.1

func (c Ctx) Response() http.ResponseWriter

Response 返回元素 ResponseWriter

func (Ctx) Return added in v0.4.1

func (c Ctx) Return(value ...interface{})

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

func (Ctx) SetCookie added in v0.3.1

func (c Ctx) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)

SetCookie 设置一个 Cookie

type Error added in v0.3.1

type Error = interface{}

Error 错误类型 类型设计 是一个函数 接收一个 实现了 error 接口的参数

type ErrorResponse

type ErrorResponse struct {
	UrlPath      string `json:"url"`
	Status       int    `json:"code"`
	ErrorMessage string `json:"error"`
	Time         string `json:"time"`
}

type Formatter added in v0.4.9

type Formatter struct {
	*logrus.TextFormatter
}

func (*Formatter) Format added in v0.4.9

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

type Group

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

group 路由分组 初始化的 分组变量不会携带全局的Use group 可以设定局部的全局Use

func (*Group) Delete added in v0.4.1

func (g *Group) Delete(url string, control Controller, middleware ...Middleware)

Delete 请求

func (*Group) Get added in v0.4.1

func (g *Group) Get(url string, control Controller, middleware ...Middleware)

Get 请求

func (*Group) Group added in v0.4.1

func (g *Group) Group(url string, middleware ...Middleware) *Group

Group 路由分组 必须以 “/” 开头分组

func (*Group) Head added in v0.4.1

func (g *Group) Head(url string, control Controller, middleware ...Middleware)

Head 请求

func (*Group) Post added in v0.4.1

func (g *Group) Post(url string, control Controller, middleware ...Middleware)

Post 请求

func (*Group) Put added in v0.4.1

func (g *Group) Put(url string, control Controller, middleware ...Middleware)

Put 请求

func (*Group) Url added in v0.4.9

func (g *Group) Url(url string, control Controller, middleware ...Middleware)

func (*Group) Use added in v0.4.1

func (g *Group) Use(middleware ...Middleware)

Use 基于 group 的分组添加 Middleware

type Log added in v0.3.8

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

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

type Middleware added in v0.2.8

type Middleware func(Ctx) bool

Middleware 中间件类型

type MultipartFile added in v0.3.1

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

func (*MultipartFile) SaveUploadedFile added in v0.3.1

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

SaveUploadedFile 保存文件

type Option added in v0.4.5

type Option func(*Aurora)

func ConfigFile

func ConfigFile(configPath string) Option

ConfigFile 指定Aurora加载配置文件

func Debug added in v0.4.8

func Debug() Option

Debug 开启debug日志

func ViperConfiguration added in v0.4.5

func ViperConfiguration(path string) Option

ViperConfiguration 配置指定配置文件

type UseConfiguration added in v0.3.9

type UseConfiguration func(interface{}) UseOption

type UseOption added in v0.3.8

type UseOption func(*Aurora)

UseOption 配置项 对 *Aurora 的指定属性进行 配置

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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