Documentation
¶
Index ¶
- type Context
- func (c *Context) BindJSON(val any) error
- func (c *Context) BindJSONOpt(val any, useNumber bool, disableUnknown bool) error
- func (c *Context) FormValue(key string) StringValue
- func (c *Context) PathValue(key string) StringValue
- func (c *Context) QueryValue(key string) StringValue
- func (c *Context) Render(templateName string, data any) error
- func (c *Context) RespJSON(status int, val any) error
- func (c *Context) RespJSONOK(val any) error
- func (c *Context) SetCookie(ck *http.Cookie)
- type FileDownloader
- type FileUploader
- type GoTemplateEngine
- type HTTPServer
- func (h *HTTPServer) Connect(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Delete(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Get(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Head(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Options(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Patch(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Post(path string, handleFunc HandleFunc)
- func (h *HTTPServer) Put(path string, handleFunc HandleFunc)
- func (h *HTTPServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)
- func (h *HTTPServer) Start(addr string) error
- func (h *HTTPServer) Trace(path string, handleFunc HandleFunc)
- func (s *HTTPServer) Use(mils ...Middleware)
- func (s *HTTPServer) UseRoute(method string, path string, mils ...Middleware)
- type HTTPServerOption
- type HandleFunc
- type Middleware
- type Server
- type StaticResourceHandler
- type StaticResourceHandlerOption
- type StringValue
- type TemplateEngine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Request *http.Request
ResponseWriter http.ResponseWriter
PathParams map[string]string
MatchedRoute string
RespData []byte
RespStatusCode int
UserValues map[string]any
// contains filtered or unexported fields
}
func (*Context) BindJSONOpt ¶
func (*Context) FormValue ¶
func (c *Context) FormValue(key string) StringValue
func (*Context) PathValue ¶
func (c *Context) PathValue(key string) StringValue
func (*Context) QueryValue ¶
func (c *Context) QueryValue(key string) StringValue
func (*Context) RespJSONOK ¶
type FileDownloader ¶ added in v0.1.1
type FileDownloader struct {
Dir string
}
func (*FileDownloader) Handle ¶ added in v0.1.1
func (f *FileDownloader) Handle() HandleFunc
Handle 文件下载
type FileUploader ¶ added in v0.1.1
type FileUploader struct {
// FileField 对应于文件在表单中的字段名字
FileField string
// FileField 对应于文件在表单中的字段名字
DstPathFunc func(*multipart.FileHeader) string
}
func (*FileUploader) Handle ¶ added in v0.1.1
func (f *FileUploader) Handle() HandleFunc
Handle 文件上传
type GoTemplateEngine ¶ added in v0.1.1
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func InitHTTPServer ¶ added in v0.1.1
func InitHTTPServer(opts ...HTTPServerOption) *HTTPServer
func (*HTTPServer) Connect ¶
func (h *HTTPServer) Connect(path string, handleFunc HandleFunc)
func (*HTTPServer) Delete ¶
func (h *HTTPServer) Delete(path string, handleFunc HandleFunc)
func (*HTTPServer) Get ¶
func (h *HTTPServer) Get(path string, handleFunc HandleFunc)
func (*HTTPServer) Head ¶
func (h *HTTPServer) Head(path string, handleFunc HandleFunc)
func (*HTTPServer) Options ¶
func (h *HTTPServer) Options(path string, handleFunc HandleFunc)
func (*HTTPServer) Patch ¶
func (h *HTTPServer) Patch(path string, handleFunc HandleFunc)
func (*HTTPServer) Post ¶
func (h *HTTPServer) Post(path string, handleFunc HandleFunc)
func (*HTTPServer) Put ¶
func (h *HTTPServer) Put(path string, handleFunc HandleFunc)
func (*HTTPServer) ServeHTTP ¶
func (h *HTTPServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)
ServeHTTP HTTPServer 处理请求的入口
func (*HTTPServer) Trace ¶
func (h *HTTPServer) Trace(path string, handleFunc HandleFunc)
func (*HTTPServer) Use ¶
func (s *HTTPServer) Use(mils ...Middleware)
func (*HTTPServer) UseRoute ¶ added in v0.1.3
func (s *HTTPServer) UseRoute(method string, path string, mils ...Middleware)
type HTTPServerOption ¶
type HTTPServerOption func(server *HTTPServer)
func ServerWithMiddleware ¶
func ServerWithMiddleware(mils ...Middleware) HTTPServerOption
func ServerWithTemplateEngine ¶ added in v0.1.1
func ServerWithTemplateEngine(templateEngine TemplateEngine) HTTPServerOption
type HandleFunc ¶
type HandleFunc func(ctx *Context)
type Middleware ¶
type Middleware func(next HandleFunc) HandleFunc
type StaticResourceHandler ¶ added in v0.1.1
type StaticResourceHandler struct {
// contains filtered or unexported fields
}
func InitStaticResourceHandler ¶ added in v0.1.1
func InitStaticResourceHandler(dir string, opts ...StaticResourceHandlerOption) (*StaticResourceHandler, error)
func (*StaticResourceHandler) Handle ¶ added in v0.1.1
func (s *StaticResourceHandler) Handle(ctx *Context)
type StaticResourceHandlerOption ¶ added in v0.1.1
type StaticResourceHandlerOption func(handler *StaticResourceHandler)
func StaticWithCache ¶ added in v0.1.1
func StaticWithCache(c *lru.Cache) StaticResourceHandlerOption
func StaticWithExtension ¶ added in v0.1.1
func StaticWithExtension(extMap map[string]string) StaticResourceHandlerOption
func StaticWithMaxFileSize ¶ added in v0.1.1
func StaticWithMaxFileSize(maxSize int) StaticResourceHandlerOption
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
func (*StringValue) AsFloat64 ¶
func (s *StringValue) AsFloat64() (float64, error)
func (*StringValue) AsInt64 ¶
func (s *StringValue) AsInt64() (int64, error)
func (*StringValue) AsUint64 ¶
func (s *StringValue) AsUint64() (uint64, error)
Click to show internal directories.
Click to hide internal directories.