Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type CtxTag
- type ErrorHandler
- type Interceptor
- type Logger
- type MultiForm
- type PostProcessor
- type Request
- func (r *Request) FormData() (map[string][]string, error)
- func (r *Request) IP() (string, error)
- func (r *Request) Json(target any) error
- func (r *Request) MultipartForm() (f *MultiForm, err error)
- func (r *Request) MultipartFormLarge(size int64) (f *MultiForm, err error)
- func (r *Request) Stream(wr io.Writer) (err error)
- func (r *Request) Text() (string, error)
- func (r *Request) UrlParam() (map[string]string, error)
- func (r *Request) WebContext() any
- type RequestHandler
- type Response
- func (r *Response) File(input io.Reader, size int64, name string) (int64, error)
- func (r *Response) Html(html string, statusCode int) (err error)
- func (r *Response) Json(target any, statusCode int) error
- func (r *Response) Sse(fun func(hf http.Flusher, r *Response)) (err error)
- func (r *Response) Text(txt string, statusCode int) (err error)
- 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 ErrorHandler ¶
type Interceptor ¶ added in v0.0.12
type PostProcessor ¶ added in v0.0.12
type Request ¶
func (*Request) MultipartForm ¶
func (*Request) MultipartFormLarge ¶ added in v0.0.12
处理更大的formdata size: 单位为 Mib
func (*Request) WebContext ¶ added in v0.0.10
type RequestHandler ¶
type Response ¶
type Response struct { http.ResponseWriter Ctx *reqCtx }
type Server ¶
type Server struct { Ctx context.Context // 全局上下文 Logger Logger // 日志输出 Config Config // 配置 ErrorHandler ErrorHandler // 统一错误处理 NotFoundHandler RequestHandler // 统一404处理 CtxDataGetter func(*http.Request) any // 上下文生成器 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 ¶ added in v0.0.12
func (s *Server) Interceptor(prefix string, interceptor Interceptor)
function around handler prefix: url prefix for interceptor
func (*Server) ListenAndServe ¶
func (*Server) PostProcessor ¶ added in v0.0.12
func (s *Server) PostProcessor(prefix string, postProcessor PostProcessor)
Click to show internal directories.
Click to hide internal directories.