index

本文列出App对象、Context对象、所有函数功能分类,所有函数名称来源godoc,总计37个类型229个函数。

App属性方法树

App对象是eudore主体对象。

名称 属性类型 作用
App App 定义App对象
App.Binder Binder 解析请求数据绑定
App.Renderer Renderer 渲染响应
App.HandlerFuncs HandlerFuncs App处理每个请求的处理函数
App.CancelError error App.Run结束的错误
App.Context context.Context App的生命周期
App.Config Config 配置
App.Config.{Parse\ParseOption} 配置解析
App.Config.{Get\Set} 配置读写
App.Logger Logger 日志器
App.Logger.{Debug\Info\Warning\Error\Fatal
\Debugf\Infof\Warningf\Errorf\Fatalf}
五级日志输出
App.Logger.{WithField\WithFields} 设置日志Fields
App.Logger.{Sync\SetLevel} 日志其他操作
App.Server Server http服务
App.Server.{SetHandler\Serve\Shutdown} 启动和关闭http服务
App.Router Router 路由器
App.Router.{HandleFunc\Match} RouterCore 路由器核心匹配和注册路由规则
App.Router.{Group\Params} 操作当前路由器的注册参数
App.Router.{AddHandler\AddController
\AddMiddleware\AddHandlerExtend}
路由器注册各类对象
App.Router.{Any\Get\Post\Put\Delete\Head\Patch}Func 指定方法注册路由规则
App.Validater Validater 校验器
App.Validater.{RegisterValidations\Validate\ValidateVar} 校验规则注册和使用
App.GetWarp GetWarp 添加Config获取类型类型转换实现
App.GetWarp.Get{Bool\Int\Int64\Uint\Uint64\Float32
\Float64\String\Bytes\Interface\Strings}
获取一个Config的值并转换成指定类型
App.ContextPool sync.Pool Context池
App.ContextPool.{Get\Put} 使用sync.Pool复用Context对象
App
App.Binder
App.Renderer
App.HandlerFuncs
App.CancelError
App.Context
App.Config
App.Config.{Parse\ParseOption}
App.Config.{Get\Set}
App.Logger
App.Logger.{Debug\Info\Warning\Error\Fatal}{\f}
App.Logger.{WithField\WithFields}
App.Logger.{Sync\SetLevel}
App.Server
App.Server.{SetHandler\Serve\Shutdown}
App.Router
App.Router.{HandleFunc\Match} RouterCore
App.Router.{Group\Params}
App.Router.{AddHandler\AddController\AddMiddleware\AddHandlerExtend}
App.Router.{Any\Get\Post\Put\Delete\Head\Patch}Func
App.Validater
App.Validater.{RegisterValidations\Validate\ValidateVar}
App.GetWarp
App.GetWarp.Get{Bool\Int\Int64\Uint\Uint64\\Float32\Float64\String\Bytes\Interface\Strings}
App.ContextPool
App.ContextPool.{Get\Put}

Context方法组

eudore.Context对象是一次请求的上下文,用于处理这次请求的操作,分为请求上下文数据、请求、参数、响应、日志输出五部分。

请求上下文数据、

请求上下问本身具有context.Context、eudore.ResponseWriter、*http.Request、eudore.Logger四个对象,提供对象读写操作方法。

func Reset(http.ResponseWriter, *http.Request)
// 四对象读写
func GetContext() context.Context
func WithContext(context.Context)
func Request() *http.Request
func Response() ResponseWriter
func Logger() Logger
func SetRequest(*http.Request)
func SetResponse(ResponseWriter)
func SetLogger(Logger)
// 处理函数
func SetHandler(int, HandlerFuncs)
func GetHandler() (int, HandlerFuncs)
func Next()
func End()
func Err() error

请求信息

// request info
func Read([]byte) (int, error)
func Host() string
func Method() string
func Path() string
func RealIP() string
func RequestID() string
func Referer() string
func ContentType() string
func Istls() bool
func Body() []byte
func Bind(interface{}) error
func BindWith(interface{}, Binder) error
func Validate(interface{}) error

参数

// param query header cookie form
func Params() *Params
func GetParam(string) string
func SetParam(string, string)
func AddParam(string, string)
func Querys() url.Values
func GetQuery(string) string
func GetHeader(string) string
func SetHeader(string, string)
func Cookies() []Cookie
func GetCookie(string) string
func SetCookie(cookie *SetCookie)
func SetCookieValue(string, string, int)
func FormValue(string) string
func FormValues() map[string][]string
func FormFile(string) *multipart.FileHeader
func FormFiles() map[string][]*multipart.FileHeader

响应

// response
func Write([]byte) (int, error)
func WriteHeader(int)
func Redirect(int, string)
func Push(string, \*http.PushOptions) error
func Render(interface{}) error
func RenderWith(interface{}, Renderer) error
func WriteString(string) error
func WriteJSON(interface{}) error
func WriteFile(string) error

日志输出

// log Logger interface
func Debug(...interface{})
func Info(...interface{})
func Warning(...interface{})
func Error(...interface{})
func Fatal(...interface{})
func Debugf(string, ...interface{})
func Infof(string, ...interface{})
func Warningf(string, ...interface{})
func Errorf(string, ...interface{})
func Fatalf(string, ...interface{})
func WithField(string, interface{}) Logger
func WithFields([]string, []interface{}) Logger

类型

所有定义public的类型,一共37个。

type App
type Binder
type Config
type ConfigParse
type Context
type ContextData
type Controller
type ControllerAutoRoute
type ControllerBase
type ControllerData
type ControllerFuncExtend
type ControllerPool
type ControllerSingleton
type ControllerView
type Cookie
type GetWarp
type HandlerExtender
type HandlerFunc
type HandlerFuncs
type Logger
type LoggerLevel
type LoggerStd
type LoggerStdConfig
type LoggerStdData
type LoggerWriter
type Params
type Renderer
type ResponseWriter
type Router
type RouterCore
type RouterStd
type Server
type ServerListenConfig
type ServerStdConfig
type SetCookie
type TimeDuration
type Validater

类型构造函数

下列为所有对象的构造函数,函数名称规则为: New{类型}{名称},例如NewConfigMap

func NewApp(options ...interface{}) *App
func NewBinderHeader(fn Binder) Binder
func NewBinderURL(fn Binder) Binder
func NewBinderValidater(fn Binder) Binder
func NewConfigEudore(i interface{}) Config
func NewConfigMap(arg interface{}) Config
func NewContextBase(app *App) Context
func NewControllerError(ctl Controller, err error) Controller
func NewGetWarp(fn func(string) interface{}) GetWarp
func NewGetWarpWithApp(app *App) GetWarp
func NewGetWarpWithConfig(c Config) GetWarp
func NewGetWarpWithMapString(data map[string]interface{}) GetWarp
func NewGetWarpWithObject(obj interface{}) GetWarp
func NewHandlerExtendBase() HandlerExtender
func NewHandlerExtendTree() HandlerExtender
func NewHandlerExtendWarp(base, last HandlerExtender) HandlerExtender
func NewExtendContextData(fn func(ContextData)) HandlerFunc
func NewStaticHandler(dir string) HandlerFunc
func NewHandlerFuncsCombine(hs1, hs2 HandlerFuncs) HandlerFuncs
func NewHandlerFuncsFilter(hs HandlerFuncs) HandlerFuncs
func NewLoggerInit() Logger
func NewLoggerStd(arg interface{}) Logger
func NewLoggerWriterFile(name string, std bool) (LoggerWriter, error)
func NewLoggerWriterRotate(name string, std bool, maxsize uint64, fn ...func(string)) (LoggerWriter, error)
func NewLoggerWriterStd() LoggerWriter
func NewParamsRoute(path string) *Params
func NewRenderHTML(temp *template.Template) Renderer
func NewRenderHTMLWithTemplate(r Renderer, temp *template.Template) Renderer
func NewRouterStd(core RouterCore) Router
func NewRouterCoreDebug(core RouterCore) RouterCore
func NewRouterCoreHost(newfn func(string) RouterCore) RouterCore
func NewRouterCoreLock(core RouterCore) RouterCore
func NewRouterCoreStd() RouterCore
func NewServerFcgi() Server
func NewServerStd(arg interface{}) Server
func NewvalidaterBase() Validater

处理函数扩展函数

定义处理函数扩展,将指定函数转换成HandlerFunc,函数规则:NewExtend{扩展类型}{函数类型}。

func NewExtendController(name string, pool ControllerPool, fn func(Context, Controller)) HandlerFunc
func NewExtendControllerFunc(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncContext(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncContextError(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncContextRender(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncContextRenderError(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncError(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncMapString(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncMapStringError(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncMapStringRender(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncMapStringRenderError(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncRender(ef ControllerFuncExtend) HandlerFunc
func NewExtendControllerFuncRenderError(ef ControllerFuncExtend) HandlerFunc
func NewExtendFunc(fn func()) HandlerFunc
func NewExtendFuncContextError(fn func(Context) error) HandlerFunc
func NewExtendFuncContextRender(fn func(Context) interface{}) HandlerFunc
func NewExtendFuncContextRenderError(fn func(Context) (interface{}, error)) HandlerFunc
func NewExtendFuncError(fn func() error) HandlerFunc
func NewExtendFuncNetHTTP1(fn func(http.ResponseWriter, *http.Request)) HandlerFunc
func NewExtendFuncNetHTTP2(fn http.HandlerFunc) HandlerFunc
func NewExtendFuncRPCMap(fn func(Context, map[string]interface{}) (interface{}, error)) HandlerFunc
func NewExtendFuncRender(fn func() interface{}) HandlerFunc
func NewExtendFuncRenderError(fn func() (interface{}, error)) HandlerFunc
func NewExtendFuncString(fn func() string) HandlerFunc
func NewExtendHandlerHTTP(h handlerHTTP) HandlerFunc
func NewExtendHandlerNetHTTP(h http.Handler) HandlerFunc
func NewExtendHandlerRPC(fn interface{}) HandlerFunc
func NewExtendHandlerStringer(fn fmt.Stringer) HandlerFunc

函数组

Bind函数

func BindDefault(ctx Context, r io.Reader, i interface{}) error
func BindForm(ctx Context, _ io.Reader, i interface{}) error
func BindHeader(ctx Context, _ io.Reader, i interface{}) error
func BindJSON(_ Context, r io.Reader, i interface{}) error
func BindURL(ctx Context, _ io.Reader, i interface{}) error
func BindXML(_ Context, r io.Reader, i interface{}) error

配置解析函数

func ConfigParseArgs(c Config) (err error)
func ConfigParseEnvs(c Config) error
func ConfigParseHelp(c Config) error
func ConfigParseJSON(c Config) error
func ConfigParseMods(c Config) error
func ConfigParseWorkdir(c Config) error

控制器注入函数

func ControllerInjectAutoRoute(controller Controller, router Router) error
func ControllerInjectSingleton(controller Controller, router Router) error
func ControllerInjectStateful(controller Controller, router Router) error
func ControllerInjectWithPool(pool ControllerPool, controller Controller, router Router) error

数据Get/Set/Convert函数

func ConvertMap(i interface{}) map[interface{}]interface{}
func ConvertMapString(i interface{}) map[string]interface{}
func ConvertMapStringWithTags(i interface{}, tags []string) map[string]interface{}
func ConvertMapWithTags(i interface{}, tags []string) map[interface{}]interface{}
func ConvertTo(source interface{}, target interface{}) error
func ConvertToWithTags(source interface{}, target interface{}, tags []string) error
func Get(i interface{}, key string) (val interface{})
func GetWithTags(i interface{}, key string, tags []string) (interface{}, error)
func Set(i interface{}, key string, val interface{}) error
func SetWithTags(i interface{}, key string, val interface{}, tags []string) error

interface{}类型转换函数

func GetBool(i interface{}) bool
func GetBytes(i interface{}) []byte
func GetFloat32(i interface{}, nums ...float32) float32
func GetFloat64(i interface{}, nums ...float64) float64
func GetInt(i interface{}, nums ...int) int
func GetInt64(i interface{}, nums ...int64) int64
func GetString(i interface{}, strs ...string) string

string类型转换函数

func GetStringBool(str string) bool
func GetStringFloat32(str string, nums ...float32) float32
func GetStringFloat64(str string, nums ...float64) float64
func GetStringInt(str string, nums ...int) int
func GetStringInt64(str string, nums ...int64) int64
func GetStringUint(str string, nums ...uint) uint
func GetStringUint64(str string, nums ...uint64) uint64
func GetStrings(i interface{}) []string
func GetUint(i interface{}, nums ...uint) uint
func GetUint64(i interface{}, nums ...uint64) uint64

请求处理函数

func HandlerEmpty(Context)
func HandlerRouter404(ctx Context)
func HandlerRouter405(ctx Context)

Render函数

func RenderDefault(ctx Context, data interface{}) error
func RenderJSON(ctx Context, data interface{}) error
func RenderText(ctx Context, data interface{}) error
func RenderXML(ctx Context, data interface{}) error

其他函数

func GetValidateStringFunc(name string) func(string) bool
func GetPanicStack(depth int) []string
func NewPrintFunc(log Logger) func(...interface{})
func SetHandlerAliasName(i interface{}, name string)
func SetHandlerFuncName(i HandlerFunc, name string)

results matching ""

    No results matching ""