Documentation ¶
Index ¶
- func SaveFile(fh *multipart.FileHeader, path string, name ...string) (string, int64, error)
- type BaseHandler
- func (handle *BaseHandler) CONNECT(ctx *Context)
- func (handle *BaseHandler) DELETE(ctx *Context)
- func (*BaseHandler) Finish(*Context)
- func (handle *BaseHandler) GET(ctx *Context)
- func (handle *BaseHandler) HEAD(ctx *Context)
- func (*BaseHandler) Init(*Context)
- func (handle *BaseHandler) OPTIONS(ctx *Context)
- func (handle *BaseHandler) PATCH(ctx *Context)
- func (handle *BaseHandler) POST(ctx *Context)
- func (handle *BaseHandler) PUT(ctx *Context)
- func (*BaseHandler) Prepare(*Context)
- func (handle *BaseHandler) TRACE(ctx *Context)
- type Context
- func (ctx *Context) Download(filename string, header map[string]string)
- func (ctx *Context) Error(statusCode int)
- func (ctx *Context) GetCookie(name string) string
- func (ctx *Context) GetCookies() []*http.Cookie
- func (ctx *Context) GetForm() (map[string]string, map[string]*multipart.FileHeader, error)
- func (ctx *Context) GetHeader(key string, v ...string) string
- func (ctx *Context) GetJSONBody(v interface{}) error
- func (ctx *Context) GetQuery() map[string]string
- func (ctx *Context) IsFinish() bool
- func (ctx *Context) JSON(v interface{}, code int, err error)
- func (ctx *Context) RecvFile(name string, path string) (string, int64, error)
- func (ctx *Context) RecvFile2(name string, path string) error
- func (ctx *Context) RecvFormFile(path string) error
- func (ctx *Context) Redirect(url string, statusCode int)
- func (ctx *Context) Remote() string
- func (ctx *Context) Render(tpl string, data interface{})
- func (ctx *Context) SetStatusCode(statusCode int)
- func (ctx *Context) Text(response []byte)
- type Entry
- type Handler
- type HandlerFunc
- func (f HandlerFunc) CONNECT(ctx *Context)
- func (f HandlerFunc) DELETE(ctx *Context)
- func (f HandlerFunc) Finish(ctx *Context)
- func (f HandlerFunc) GET(ctx *Context)
- func (f HandlerFunc) HEAD(ctx *Context)
- func (f HandlerFunc) Init(ctx *Context)
- func (f HandlerFunc) OPTIONS(ctx *Context)
- func (f HandlerFunc) PATCH(ctx *Context)
- func (f HandlerFunc) POST(ctx *Context)
- func (f HandlerFunc) PUT(ctx *Context)
- func (f HandlerFunc) Prepare(ctx *Context)
- func (f HandlerFunc) TRACE(ctx *Context)
- type Multiplexer
- func (mux Multiplexer) FindRoute(path string) *Entry
- func (mux *Multiplexer) Handle(path string, handler http.Handler)
- func (mux *Multiplexer) HandleFunc(path string, f http.HandlerFunc)
- func (mux *Multiplexer) Route(path string, handler Handler)
- func (mux *Multiplexer) RouteFunc(path string, f HandlerFunc)
- func (mux Multiplexer) String() string
- type Option
- type Options
- type Web
- func (s *Web) Close() error
- func (s *Web) DebugPprof()
- func (s *Web) Handle(path string, handler http.Handler)
- func (s *Web) HandleFs(srtipPath, path string)
- func (s *Web) HandleFunc(path string, f http.HandlerFunc)
- func (s *Web) Init(opts ...Option)
- func (s *Web) Load(v interface{}) error
- func (s *Web) Route(path string, handle Handler)
- func (s *Web) RouteFunc(path string, f HandlerFunc)
- func (s *Web) Run(ctx context.Context) error
- func (s *Web) ServeHTTP(resp http.ResponseWriter, req *http.Request)
- func (s *Web) SetLog(log log.Logger)
- func (s *Web) String() string
- func (s *Web) Use(f ...func(*Context))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct { http.ResponseWriter *http.Request Timestamp time.Time log.Logger // contains filtered or unexported fields }
Context context
func (*Context) GetForm ¶
GetForm formdata, Content-Type must be multipart/form-data. TODO: RemoveAll removes any temporary files associated with a Form.
func (*Context) GetJSONBody ¶
GetJSONBody get json body args
func (*Context) RecvFormFile ¶
RecvFormFile recv form file
func (*Context) SetStatusCode ¶
type Entry ¶
type Entry struct { MyInterface Handler // contains filtered or unexported fields }
Entry route entry point
type Handler ¶
type Handler interface { Init(*Context) Prepare(*Context) CONNECT(*Context) OPTIONS(*Context) HEAD(*Context) GET(*Context) POST(*Context) DELETE(*Context) PUT(*Context) TRACE(*Context) PATCH(*Context) Finish(*Context) }
Handler interface
type Multiplexer ¶
type Multiplexer []*Entry
Multiplexer mux
func (Multiplexer) FindRoute ¶
func (mux Multiplexer) FindRoute(path string) *Entry
FindRoute find router
func (*Multiplexer) Handle ¶
func (mux *Multiplexer) Handle(path string, handler http.Handler)
Handle std http handle
func (*Multiplexer) HandleFunc ¶
func (mux *Multiplexer) HandleFunc(path string, f http.HandlerFunc)
HandleFunc handlefunc
func (*Multiplexer) Route ¶
func (mux *Multiplexer) Route(path string, handler Handler)
Route handle
func (*Multiplexer) RouteFunc ¶
func (mux *Multiplexer) RouteFunc(path string, f HandlerFunc)
RouteFunc route handlerFunc
func (Multiplexer) String ¶
func (mux Multiplexer) String() string
type Options ¶
type Options struct { Address string `yaml:"address" json:"address,omitempty"` CertFile string KeyFile string ReadTimeout int ReadHeaderTimeout int WriteTimeout int IdleTimeout int MaxHeaderBytes int StaticPaths map[string]string //静态文件路径头 strings.Trim(path, staticPath) }
Options options
type Web ¶
type Web struct { Log log.Logger Mids []func(*Context) Mux Multiplexer *http.Server sync.Pool // contains filtered or unexported fields }
Web service
func (*Web) HandleFunc ¶
func (s *Web) HandleFunc(path string, f http.HandlerFunc)
HandleFunc http Handle func
func (*Web) RouteFunc ¶
func (s *Web) RouteFunc(path string, f HandlerFunc)
RouteFunc route handlerfunc
Source Files ¶
Click to show internal directories.
Click to hide internal directories.