Versions in this module Expand all Collapse all v1 v1.2.0 Mar 17, 2018 Changes in this version + const CONFIG_DIR + const FilepathKey + const GLOBAL_CONFIG_FILE + const HeaderAccept + const HeaderAcceptEncoding + const HeaderAccessControlAllowCredentials + const HeaderAccessControlAllowHeaders + const HeaderAccessControlAllowMethods + const HeaderAccessControlAllowOrigin + const HeaderAccessControlExposeHeaders + const HeaderAccessControlMaxAge + const HeaderAccessControlRequestHeaders + const HeaderAccessControlRequestMethod + const HeaderAuthorization + const HeaderCacheControl + const HeaderContentDescription + const HeaderContentDisposition + const HeaderContentEncoding + const HeaderContentLength + const HeaderContentSecurityPolicy + const HeaderContentTransferEncoding + const HeaderContentType + const HeaderCookie + const HeaderExpires + const HeaderIfModifiedSince + const HeaderLastModified + const HeaderLocation + const HeaderOrigin + const HeaderPragma + const HeaderReferer + const HeaderServer + const HeaderSetCookie + const HeaderStrictTransportSecurity + const HeaderUpgrade + const HeaderUserAgent + const HeaderVary + const HeaderWWWAuthenticate + const HeaderXCSRFToken + const HeaderXContentTypeOptions + const HeaderXForwardedFor + const HeaderXForwardedProto + const HeaderXFrameOptions + const HeaderXHTTPMethodOverride + const HeaderXRealIP + const HeaderXRequestedWith + const HeaderXXSSProtection + const MB + const MIMEApplicationForm + const MIMEApplicationJSON + const MIMEApplicationJSONCharsetUTF8 + const MIMEApplicationJavaScript + const MIMEApplicationJavaScriptCharsetUTF8 + const MIMEApplicationMsgpack + const MIMEApplicationProtobuf + const MIMEApplicationXML + const MIMEApplicationXMLCharsetUTF8 + const MIMEMultipartForm + const MIMEOctetStream + const MIMETextHTML + const MIMETextHTMLCharsetUTF8 + const MIMETextPlain + const MIMETextPlainCharsetUTF8 + const MIMETextXML + const MIMETextXMLCharsetUTF8 + const MinShutdownTimeout + const NETTYPE_HTTP + const NETTYPE_HTTPS + const NETTYPE_LETSENCRYPT + const NETTYPE_UNIX_HTTP + const NETTYPE_UNIX_HTTPS + const NETTYPE_UNIX_LETSENCRYPT + const TAG_PARAM + const VERSION + var BytesToString = goutil.BytesToString + var CamelString = goutil.CamelString + var ErrNoParamHandler = errors.New("handler does not define any parameter tags") + var ErrNotStructPtr = errors.New("handler must be a structure type or a structure pointer type") + var FileExists = goutil.FileExists + var GrepFile = goutil.GrepFile + var JsQueryEscape = goutil.JsQueryEscape + var JsQueryUnescape = goutil.JsQueryUnescape + var ObjectName = goutil.ObjectName + var RESTfulMethodList = []string + var RandomString = goutil.URLRandomString + var RelPath = goutil.RelPath + var SearchFile = goutil.SearchFile + var SelfChdir = goutil.SelfChdir + var SelfDir = goutil.SelfDir + var SelfPath = goutil.SelfPath + var SnakeString = goutil.SnakeString + var StringToBytes = goutil.StringToBytes + var WalkDirs = goutil.WalkDirs + func CleanToURL(p string) string + func CloseLog() + func ContentTypeByExtension(ext string) string + func Critical(args ...interface{}) + func Criticalf(format string, args ...interface{}) + func Debug(args ...interface{}) + func Debugf(format string, args ...interface{}) + func DecodeBody(dest reflect.Value, body []byte) error + func Error(args ...interface{}) + func Errorf(format string, args ...interface{}) + func Fatal(args ...interface{}) + func Fatalf(format string, args ...interface{}) + func HandleBinderror(ctx *Context, err error) + func HandleError(ctx *Context, errStr string, status int) + func Info(args ...interface{}) + func Infof(format string, args ...interface{}) + func IsHandlerWithoutPath(handler Handler) bool + func JoinStatic(shortFilename string) string + func LogDir() string + func MapParamName(fieldName string) (paramName string) + func NewLog() *logging.Logger + func Notice(args ...interface{}) + func Noticef(format string, args ...interface{}) + func Panic(args ...interface{}) + func Panicf(format string, args ...interface{}) + func Print(args ...interface{}) + func Printf(format string, args ...interface{}) + func Reboot(timeout ...time.Duration) + func RemoveUseless() + func RenderVar(name string, v interface{}) + func Run() + func Running(name string, version ...string) bool + func SetBinderrorFunc(binderrorFunc BinderrorFunc) + func SetBodydecoder(bodydecoder apiware.Bodydecoder) + func SetErrorFunc(errorFunc ErrorFunc) + func SetParamNameMapper(paramNameMapper apiware.ParamNameMapper) + func SetShutdown(timeout time.Duration, preCloseFunc, postCloseFunc func() error) + func SetStatic(dir string, nocompress bool, nocache bool, handlers ...Handler) + func SetUpload(dir string, nocompress bool, nocache bool, handlers ...Handler) + func Shutdown(timeout ...time.Duration) + func StaticDir() string + func SyncINI(structPtr interface{}, f func(onecUpdateFunc func() error) error, ...) error + func ToAPIHandler(handler Handler) (*apiHandler, error) + func UploadDir() string + func Warning(args ...interface{}) + func Warningf(format string, args ...interface{}) + func WritePid(pidFilename string) error + type APIDoc interface + Doc func() Doc + type APIHandler interface + type APIdocConfig struct + Desc string + Email string + Enable bool + License string + LicenseURL string + NoLimit bool + Path string + RealIP bool + TermsURL string + Whitelist []string + func (conf *APIdocConfig) Comb() + type BinderrorFunc func(ctx *Context, err error) + type Bodydecoder interface + Decode func(dest reflect.Value, body []byte) error + type CacheConfig struct + Enable bool + ExpireSecond int + SizeMB int64 + type CacheFile struct + func NewFile(b []byte, fileInfo os.FileInfo) *CacheFile + func (c *CacheFile) Close() error + func (c *CacheFile) Readdir(count int) ([]os.FileInfo, error) + func (c *CacheFile) Stat() (os.FileInfo, error) + type Config struct + APIdoc APIdocConfig + Addrs []string + HttpRedirectHttps bool + LetsencryptDir string + MultipartMaxMemoryMB int64 + NetTypes []string + PrintBody bool + ReadTimeout time.Duration + Router RouterConfig + Session SessionConfig + SlowResponseThreshold time.Duration + TLSCertFile string + TLSKeyFile string + UNIXFileMode string + WriteTimeout time.Duration + XSRF XSRFConfig + func NewDefaultConfig() *Config + type Context struct + R *http.Request + W *Response + func (ctx *Context) AcceptHTML() bool + func (ctx *Context) AcceptJSON() bool + func (ctx *Context) AcceptXML() bool + func (ctx *Context) BindBizParam(dest interface{}, key string) error + func (ctx *Context) BindForm(structObject interface{}) error + func (ctx *Context) BindJSON(jsonObject interface{}) error + func (ctx *Context) BindXML(xmlObject interface{}) error + func (ctx *Context) BizParam(key string) string + func (ctx *Context) Bytes(status int, contentType string, content []byte) error + func (ctx *Context) Committed() bool + func (ctx *Context) CookieParam(key string) string + func (ctx *Context) Data(key interface{}) interface{} + func (ctx *Context) DataAll() map[interface{}]interface{} + func (ctx *Context) Del(key interface{}) + func (ctx *Context) DelSession(key interface{}) + func (ctx *Context) DestroySession() + func (ctx *Context) Domain() string + func (ctx *Context) Error(status int, errStr string) + func (ctx *Context) File(localFilename string, showFilename ...string) + func (ctx *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error) + func (ctx *Context) FormParam(key string) string + func (ctx *Context) FormParamAll() url.Values + func (ctx *Context) FormParams(key string) []string + func (ctx *Context) GetSession(key interface{}) interface{} + func (ctx *Context) HTML(status int, html string) error + func (ctx *Context) HasData(key interface{}) bool + func (ctx *Context) HasFormFile(key string) bool + func (ctx *Context) HeaderParam(key string) string + func (ctx *Context) HeaderParamAll() http.Header + func (ctx *Context) Host() string + func (ctx *Context) IP() string + func (ctx *Context) Is(method string) bool + func (ctx *Context) IsAjax() bool + func (ctx *Context) IsBreak() bool + func (ctx *Context) IsCachable() bool + func (ctx *Context) IsClientError() bool + func (ctx *Context) IsDelete() bool + func (ctx *Context) IsEmpty() bool + func (ctx *Context) IsForbidden() bool + func (ctx *Context) IsGet() bool + func (ctx *Context) IsHead() bool + func (ctx *Context) IsNotFound() bool + func (ctx *Context) IsOk() bool + func (ctx *Context) IsOptions() bool + func (ctx *Context) IsPatch() bool + func (ctx *Context) IsPost() bool + func (ctx *Context) IsPut() bool + func (ctx *Context) IsRedirect() bool + func (ctx *Context) IsSecure() bool + func (ctx *Context) IsServerError() bool + func (ctx *Context) IsSuccessful() bool + func (ctx *Context) IsUpload() bool + func (ctx *Context) IsWebsocket() bool + func (ctx *Context) JSON(status int, data interface{}, isIndent ...bool) error + func (ctx *Context) JSONBlob(status int, b []byte) error + func (ctx *Context) JSONMsg(status int, msgcode int, info interface{}, isIndent ...bool) error + func (ctx *Context) JSONOrXML(status int, data interface{}, isIndent ...bool) error + func (ctx *Context) JSONP(status int, callback string, data interface{}, isIndent ...bool) error + func (ctx *Context) LimitedBodyBytes() []byte + func (ctx *Context) Log() *logging.Logger + func (ctx *Context) Method() string + func (ctx *Context) ModifyPath(p string) + func (ctx *Context) Next() + func (ctx *Context) NoContent(status int) + func (ctx *Context) Param(key string) string + func (ctx *Context) ParseFormOrMulitForm(maxMemory int64) error + func (ctx *Context) Path() string + func (ctx *Context) PathParam(key string) string + func (ctx *Context) PathParamAll() PathParams + func (ctx *Context) Port() int + func (ctx *Context) Protocol() string + func (ctx *Context) Proxy() []string + func (ctx *Context) QueryParam(key string) string + func (ctx *Context) QueryParamAll() url.Values + func (ctx *Context) QueryParams(key string) []string + func (ctx *Context) RealIP() string + func (ctx *Context) Redirect(status int, urlStr string) error + func (ctx *Context) Referer() string + func (ctx *Context) Render(status int, name string, data Map) error + func (ctx *Context) ReverseProxy(targetUrlBase string, pathAppend bool) error + func (ctx *Context) SaveFile(key string, cover bool, newfname ...string) (savedFileInfo SavedFileInfo, err error) + func (ctx *Context) SaveFiles(key string, cover bool, newfname ...string) (savedFileInfos []SavedFileInfo, err error) + func (ctx *Context) Scheme() string + func (ctx *Context) SecureCookieParam(secret, key string) (string, bool) + func (ctx *Context) SessionRegenerateID() + func (ctx *Context) SetCookie(name string, value string, others ...interface{}) + func (ctx *Context) SetData(key, val interface{}) + func (ctx *Context) SetHeader(key, val string) + func (ctx *Context) SetSecureCookie(secret, name, value string, others ...interface{}) + func (ctx *Context) SetSession(key interface{}, value interface{}) + func (ctx *Context) Site() string + func (ctx *Context) Size() int64 + func (ctx *Context) Status() int + func (ctx *Context) Stop() + func (ctx *Context) Stopped() bool + func (ctx *Context) String(status int, format string, s ...interface{}) error + func (ctx *Context) URI() string + func (ctx *Context) URL() *url.URL + func (ctx *Context) UserAgent() string + func (ctx *Context) XML(status int, data interface{}, isIndent ...bool) error + func (ctx *Context) XMLBlob(status int, b []byte) error + func (ctx *Context) XSRFFormHTML() string + func (ctx *Context) XSRFToken(specifiedExpiration ...int) string + type Doc struct + Note string + Params []ParamInfo + Return interface{} + type ErrorFunc func(ctx *Context, errStr string, status int) + type FileInfo struct + func (info *FileInfo) IsDir() bool + func (info *FileInfo) ModTime() time.Time + func (info *FileInfo) Mode() os.FileMode + func (info *FileInfo) Name() string + func (info *FileInfo) Size() int64 + func (info *FileInfo) Sys() interface{} + type FileServerManager struct + func (c *FileServerManager) FileServer(fs FileSystem) Handler + func (c *FileServerManager) Get(name string) (http.File, error) + func (c *FileServerManager) Open(name string, encoding string, nocache bool) (http.File, error) + func (c *FileServerManager) OpenFS(ctx *Context, name string, fs FileSystem) (http.File, error) + func (c *FileServerManager) ServeContent(ctx *Context, name string, modtime time.Time, content io.ReadSeeker) + func (c *FileServerManager) ServeFile(ctx *Context, name string, nocompressAndNocache ...bool) + func (c *FileServerManager) Set(name string, body []byte, fileInfo os.FileInfo, encoding string) (http.File, error) + type FileSystem interface + Nocache func() bool + Nocompress func() bool + func DirFS(root string, nocompressAndNocache ...bool) FileSystem + func FS(fs http.FileSystem, nocompressAndNocache ...bool) FileSystem + func MarkdownFS(root string, nocompressAndNocache ...bool) FileSystem + func RenderFS(root string, suffix string, tplVar Map) FileSystem + type Framework struct + func AllFrames() []*Framework + func GetFrame(name string, version ...string) (*Framework, bool) + func New(name string, version ...string) *Framework + func NewWithConfig(config *Config, name string, version ...string) *Framework + func (frame *Framework) CloseLog() + func (frame *Framework) Config() Config + func (frame *Framework) ConfigFilename() string + func (frame *Framework) Filter(fn ...HandlerFunc) *Framework + func (frame *Framework) Log() *logging.Logger + func (frame *Framework) MuxAPIsForRouter() []*MuxAPI + func (frame *Framework) Name() string + func (frame *Framework) NameWithVersion() string + func (frame *Framework) NewAPI(methodset Methodset, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewDELETE(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewGET(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewGroup(pattern string, children ...*MuxAPI) *MuxAPI + func (frame *Framework) NewHEAD(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedAPI(name string, methodset Methodset, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedDELETE(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedGET(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedGroup(name string, pattern string, children ...*MuxAPI) *MuxAPI + func (frame *Framework) NewNamedHEAD(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedOPTIONS(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedPATCH(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedPOST(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedPUT(name string, pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewNamedStatic(name, pattern string, root string, nocompressAndNocache ...bool) *MuxAPI + func (frame *Framework) NewNamedStaticFS(name, pattern string, fs FileSystem) *MuxAPI + func (frame *Framework) NewOPTIONS(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewPATCH(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewPOST(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewPUT(pattern string, handlers ...Handler) *MuxAPI + func (frame *Framework) NewStatic(pattern string, root string, nocompressAndNocache ...bool) *MuxAPI + func (frame *Framework) NewStaticFS(pattern string, fs FileSystem) *MuxAPI + func (frame *Framework) Route(children ...*MuxAPI) *MuxAPI + func (frame *Framework) Run() + func (frame *Framework) Running() bool + func (frame *Framework) ServeHTTP(w http.ResponseWriter, req *http.Request) + func (frame *Framework) Version() string + type GlobalConfig struct + Cache CacheConfig + Gzip GzipConfig + Log LogConfig + type GlobalVariables struct + type GzipConfig struct + CompressLevel int + Enable bool + Methods []string + MinLength int + type Handle func(*Context, PathParams) + type Handler interface + Serve func(ctx *Context) error + func WrapDoc(fn HandlerFunc, note string, ret interface{}, params ...ParamInfo) Handler + type HandlerChain []Handler + type HandlerFunc func(ctx *Context) error + func (h HandlerFunc) Serve(ctx *Context) error + type HandlerWithBody interface + type HandlerWithoutPath interface + type JSONMsg struct + Code int + Info interface{} + type LogConfig struct + AsyncLen int + ConsoleEnable bool + ConsoleLevel string + FileEnable bool + FileLevel string + type Map map[string]interface + type Methodset string + func (m *Methodset) Methods() []string + type MuxAPI struct + func (mux *MuxAPI) API(methodset Methodset, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) Children() []*MuxAPI + func (mux *MuxAPI) DELETE(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) Family() []*MuxAPI + func (mux *MuxAPI) GET(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) Group(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) HEAD(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) HandlerProgeny() []*MuxAPI + func (mux *MuxAPI) HasMethod(method string) bool + func (mux *MuxAPI) IsGroup() bool + func (mux *MuxAPI) Methods() []string + func (mux *MuxAPI) Name() string + func (mux *MuxAPI) NamedAPI(name string, methodset Methodset, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedDELETE(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedGET(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedGroup(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedHEAD(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedOPTIONS(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedPATCH(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedPOST(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedPUT(name string, pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) NamedStatic(name, pattern string, root string, nocompressAndNocache ...bool) *MuxAPI + func (mux *MuxAPI) NamedStaticFS(name, pattern string, fs FileSystem) *MuxAPI + func (mux *MuxAPI) Notes() []Notes + func (mux *MuxAPI) OPTIONS(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) PATCH(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) POST(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) PUT(pattern string, handlers ...Handler) *MuxAPI + func (mux *MuxAPI) ParamInfos() []ParamInfo + func (mux *MuxAPI) Parent() *MuxAPI + func (mux *MuxAPI) Path() string + func (mux *MuxAPI) Progeny() []*MuxAPI + func (mux *MuxAPI) Static(pattern string, root string, nocompressAndNocache ...bool) *MuxAPI + func (mux *MuxAPI) StaticFS(pattern string, fs FileSystem) *MuxAPI + func (mux *MuxAPI) Use(handlers ...Handler) *MuxAPI + type MuxAPIs []*MuxAPI + func (ends MuxAPIs) Len() int + func (ends MuxAPIs) Less(i, j int) bool + func (ends MuxAPIs) Swap(i, j int) + type Notes struct + Note string + Return interface{} + type ParamInfo struct + Desc string + In string + Model interface{} + Name string + Required bool + type PathParam struct + Key string + Value string + type PathParams []PathParam + func (ps PathParams) ByName(name string) string + func (ps PathParams) Get(name string) (string, bool) + func (ps PathParams) Replace(name string, value string, n int) bool + type PresetStatic struct + type Render struct + func GetRender() *Render + func (render *Render) Render(filename string, data Map) ([]byte, error) + func (render *Render) RenderFromBytesWithName(filename string, fbytes []byte, data Map) ([]byte, error) + func (render *Render) TemplateVar(name string, v interface{}) + type Response struct + func (resp *Response) AddCookie(cookie *http.Cookie) + func (resp *Response) CloseNotify() <-chan bool + func (resp *Response) Committed() bool + func (resp *Response) DelCookie() + func (resp *Response) Flush() + func (resp *Response) Header() http.Header + func (resp *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) + func (resp *Response) ReadFrom(src io.Reader) (int64, error) + func (resp *Response) SetCookie(cookie *http.Cookie) + func (resp *Response) Size() int64 + func (resp *Response) Status() int + func (resp *Response) Write(b []byte) (int, error) + func (resp *Response) WriteHeader(status int) + type RouterConfig struct + DefaultStatic bool + DefaultUpload bool + HandleMethodNotAllowed bool + HandleOPTIONS bool + RedirectFixedPath bool + RedirectTrailingSlash bool + type SavedFileInfo struct + Size int64 + Url string + type Server struct + type SessionConfig struct + AutoSetCookie bool + CookieLifeSecond int + Domain string + Enable bool + EnableSidInHttpHeader bool + EnableSidInUrlQuery bool + GcLifeSecond int64 + MaxLifeSecond int64 + Name string + NameInHttpHeader string + Provider string + ProviderConfig string + type Tpl struct + type XSRFConfig struct + Enable bool + ExpireSecond int + Key string