Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type Ctx
- func (r *Ctx) File(input io.Reader, size int64, name string) (int64, error)
- func (r *Ctx) FormData() (map[string][]string, error)
- func (r *Ctx) Html(statusCode int, html string) (err error)
- func (r *Ctx) IP() (string, error)
- func (r *Ctx) Json(statusCode int, target any) error
- func (r *Ctx) MultipartForm() (f *MultiForm, err error)
- func (r *Ctx) MultipartFormLarge(size int64) (f *MultiForm, err error)
- func (r *Ctx) ParseJson(target any) error
- func (r *Ctx) ParseText() (string, error)
- func (r *Ctx) Sse(fun func(hf http.Flusher, r *Ctx)) (err error)
- func (r *Ctx) Stream(wr io.Writer) (err error)
- func (r *Ctx) Text(statusCode int, txt string) (err error)
- func (r *Ctx) UrlParam() (map[string]string, error)
- func (r *Ctx) WebContext() any
- type CtxTag
- type ErrorHandler
- type Interceptor
- type Logger
- type MultiForm
- type PostProcessor
- type RequestHandler
- type Server
- func (s *Server) Handle(path string, method string, handler RequestHandler)
- func (s *Server) Interceptor(prefix string, interceptor Interceptor)
- func (s *Server) ListenAndServe() error
- func (s *Server) PostProcessor(prefix string, postProcessor PostProcessor)
- func (s *Server) Static(path, static string)
- func (s *Server) Stop()
- type TlsConfig
Constants ¶
View Source
const ( LvlDebug = 0 LvlInfo = 1 LvlWarn = 2 LvlError = 3 )
Variables ¶
View Source
var LvlName = [4]string{"DEBUG", "INFO", "WARN", "ERROR"}
Functions ¶
This section is empty.
Types ¶
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
func (*Ctx) MultipartForm ¶
func (*Ctx) MultipartFormLarge ¶
处理更大的formdata size: 单位为 Mib
func (*Ctx) WebContext ¶
type ErrorHandler ¶
type Interceptor ¶
type PostProcessor ¶
type RequestHandler ¶
type RequestHandler func(Ctx)
type Server ¶
type Server struct { Ctx context.Context // 全局上下文 Logger Logger // 日志输出 Config Config // 配置 ErrorHandler ErrorHandler // 统一错误处理 NotFoundHandler RequestHandler // 统一404处理 WebContext any // 全局web上下文(所有连接共享), 会被放到Request中 // contains filtered or unexported fields }
func (*Server) Handle ¶
func (s *Server) Handle(path string, method string, handler RequestHandler)
listen method on path path: listen path (if end with '/' ,will listen all start with $path) method: listen method such as 'GET', 'POST', 'PUT', 'DELETE' handler: function handler ======= 监听方法 path: 路径 (如果以 '/' 为结尾,则会监听所有以$path开头的路径) method: 监听的服务器方法 handler: 执行方法的句柄
func (*Server) Interceptor ¶
func (s *Server) Interceptor(prefix string, interceptor Interceptor)
function around handler prefix: url prefix for interceptor
func (*Server) ListenAndServe ¶
func (*Server) PostProcessor ¶
func (s *Server) PostProcessor(prefix string, postProcessor PostProcessor)
Click to show internal directories.
Click to hide internal directories.