leego

package module
v0.0.0-...-68342b8 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetMaxMultipartMemory

func SetMaxMultipartMemory(size int64)

Types

type Context

type Context struct {
	StatusCode int
	// contains filtered or unexported fields
}

Context 定义上下文的结构

func (*Context) GetFormFile

func (own *Context) GetFormFile(filename string) (multipart.File, *multipart.FileHeader, error)

func (*Context) GetFormValue

func (own *Context) GetFormValue(key string) string

func (*Context) GetHeader

func (own *Context) GetHeader(key string) string

func (*Context) GetHost

func (own *Context) GetHost() string

func (*Context) GetMethod

func (own *Context) GetMethod() string

func (*Context) GetMultipartFormValue

func (own *Context) GetMultipartFormValue(key string) string

func (*Context) GetPathValue

func (own *Context) GetPathValue(name string) string

func (*Context) GetPostFormValue

func (own *Context) GetPostFormValue(key string) string

func (*Context) GetProtocol

func (own *Context) GetProtocol() string

func (*Context) GetRequest

func (own *Context) GetRequest() *http.Request

func (*Context) GetResponse

func (own *Context) GetResponse() http.ResponseWriter

func (*Context) GetSeriveName

func (own *Context) GetSeriveName() string

func (*Context) GetURL

func (own *Context) GetURL() *url.URL

func (*Context) QueryPageAndLimit

func (own *Context) QueryPageAndLimit() (page, limit int, err error)

func (*Context) QueryValue

func (own *Context) QueryValue(key string) string

func (*Context) ReadJson

func (own *Context) ReadJson(data any) error

func (*Context) ResponseBytes

func (own *Context) ResponseBytes(code int, data []byte) error

func (*Context) ResponseFail

func (own *Context) ResponseFail(code int, error string)

func (*Context) ResponseFile

func (own *Context) ResponseFile(filename string) error

func (*Context) ResponseFileContent

func (own *Context) ResponseFileContent(filename string) error

func (*Context) ResponseHTML

func (own *Context) ResponseHTML(filename, tmplname string, data any) error

func (*Context) ResponseJSON

func (own *Context) ResponseJSON(code int, data any) error

func (*Context) ResponseSSE

func (own *Context) ResponseSSE(sse func() <-chan []byte) (err error)

func (*Context) ResponseString

func (own *Context) ResponseString(code int, data string) error

func (*Context) ResponseUpgrade

func (own *Context) ResponseUpgrade(upgrade func(conn net.Conn)) error

func (*Context) SetHeader

func (own *Context) SetHeader(key, value string)

func (*Context) WithContext

func (own *Context) WithContext(ctx context.Context) *Context

func (*Context) WriteCode

func (own *Context) WriteCode(code int)

type Engine

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

Engine 定义引擎的结构

func NewDefaultEngine

func NewDefaultEngine(service string) *Engine

func NewEngine

func NewEngine(service string) *Engine

NewEngine 新建一个引擎

func (Engine) DELETE

func (own Engine) DELETE(part string, handle HandleFunc, name ...string)

DELETE 给当前路由组添加一个处理 DELETE 方法的处理器

func (Engine) GET

func (own Engine) GET(part string, handle HandleFunc, name ...string)

GET 给当前路由组添加一个处理 GET 方法的处理器

func (*Engine) GetServiceName

func (own *Engine) GetServiceName() string

func (Engine) Group

func (own Engine) Group(prefix string) *group

Group 在当前路由组的基础上创建一个新的路由组

func (*Engine) ListenAndServe

func (own *Engine) ListenAndServe(opts *Options)

ListenAndServe 启动一个 HTTP 服务

func (*Engine) ListenAndServeTLS

func (own *Engine) ListenAndServeTLS(opts *Options)

ListenAndServeTLS 启动一个 HTTPS 服务

func (Engine) POST

func (own Engine) POST(part string, handle HandleFunc, name ...string)

POST 给当前路由组添加一个处理 POST 方法的处理器

func (Engine) PUT

func (own Engine) PUT(part string, handle HandleFunc, name ...string)

PUT 给当前路由组添加一个处理 PUT 方法的处理器

func (*Engine) WithInterceptors

func (own *Engine) WithInterceptors(interceptors ...Interceptor) *Engine

func (Engine) WithMiddlewares

func (own Engine) WithMiddlewares(middlewares ...MiddlewareFunc) *group

WithMiddlewares 给当前路由组添加中间件

func (Engine) WithStatics

func (own Engine) WithStatics(relativePath string, root string, name ...string) *group

WithStatics 给当前路由组添加静态文件服务接口

type HandleFunc

type HandleFunc func(ctx *Context)

HandleFunc 定义处理函数的类型

type Handler

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

Handler 定义处理器的结构

func (*Handler) ServeHTTP

func (own *Handler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP 实现 http.Handler 接口

func (*Handler) ServeInit

func (own *Handler) ServeInit()

ServeInit (在启动服务之前)初始化处理器

func (*Handler) WithMiddlewares

func (own *Handler) WithMiddlewares(middlewares ...MiddlewareFunc) *Handler

WithMiddlewares 给处理器添加中间件

type Interceptor

type Interceptor func(http.Handler) http.Handler

func Recover

func Recover() Interceptor

recover 异常恢复的拦截器

type Json

type Json map[string]any

Json 定义一个简单的 Json 类型

type MiddlewareFunc

type MiddlewareFunc func(HandleFunc) HandleFunc

MiddlewareFunc 定义处理器中间件函数的类型

func AuthFromHubuByHTTP

func AuthFromHubuByHTTP(method, url string) MiddlewareFunc

AuthFromHubuByHTTP 通过 HTTP 协议到 Hubu 进行接口请求鉴权,请求头需要携带 Hubu-User-Id

func AuthFromHubuByRPC

func AuthFromHubuByRPC(host string) MiddlewareFunc

AuthFromHubuByRPC 通过 RPC(gob) 协议到 Hubu 进行接口请求鉴权,请求头需要携带 Hubu-User-Id

func Cors

func Cors(cors *cors.CORS) MiddlewareFunc

Cors 跨域处理的中间件

func Log

func Log() MiddlewareFunc

Log 打印日志的中间件

type Options

type Options struct {
	Addr        string
	TLSCertFile string
	TLSKeyFile  string
}

Options 定义引擎配置参数的结构

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳