Versions in this module Expand all Collapse all v2 v2.0.1 Apr 3, 2023 v2.0.0 Apr 3, 2023 Changes in this version + const DefaultDomainName + const DefaultServerName + const FreePortAddress + const HandlerTypeHandler + const HandlerTypeHook + const HandlerTypeMiddleware + const HandlerTypeObject + const HeaderXUrlPath + const HookAfterOutput + const HookAfterServe + const HookBeforeOutput + const HookBeforeServe + const ServerStatusRunning + const ServerStatusStopped + const UriTypeAllLower + const UriTypeCamel + const UriTypeDefault + const UriTypeFullName + const WsMsgBinary + const WsMsgClose + const WsMsgPing + const WsMsgPong + const WsMsgText + var ErrNeedJsonBody = gerror.NewOption(gerror.Option{ ... }) + func BuildParams(params interface{}, noUrlEncode ...bool) (encodedParamStr string) + func MiddlewareCORS(r *Request) + func MiddlewareHandlerResponse(r *Request) + func MiddlewareJsonBody(r *Request) + func RestartAllServer(ctx context.Context, newExeFilePath ...string) error + func ShutdownAllServer(ctx context.Context) error + func StartPProfServer(port int, pattern ...string) + func Wait() + type CORSOptions struct + AllowCredentials string + AllowDomain []string + AllowHeaders string + AllowMethods string + AllowOrigin string + ExposeHeaders string + MaxAge int + type Cookie struct + func GetCookie(r *Request) *Cookie + func (c *Cookie) Contains(key string) bool + func (c *Cookie) Flush() + func (c *Cookie) Get(key string, def ...string) *gvar.Var + func (c *Cookie) GetSessionId() string + func (c *Cookie) Map() map[string]string + func (c *Cookie) Remove(key string) + func (c *Cookie) RemoveCookie(key, domain, path string) + func (c *Cookie) Set(key, value string) + func (c *Cookie) SetCookie(key, value, domain, path string, maxAge time.Duration, ...) + func (c *Cookie) SetHttpCookie(httpCookie *http.Cookie) + func (c *Cookie) SetSessionId(id string) + type CookieOptions struct + HttpOnly bool + SameSite http.SameSite + Secure bool + type DefaultHandlerResponse struct + Code int + Data interface{} + Message string + type Domain struct + func (d *Domain) BindHandler(pattern string, handler interface{}) + func (d *Domain) BindHookHandler(pattern string, hook string, handler HandlerFunc) + func (d *Domain) BindHookHandlerByMap(pattern string, hookMap map[string]HandlerFunc) + func (d *Domain) BindMiddleware(pattern string, handlers ...HandlerFunc) + func (d *Domain) BindMiddlewareDefault(handlers ...HandlerFunc) + func (d *Domain) BindObject(pattern string, obj interface{}, methods ...string) + func (d *Domain) BindObjectMethod(pattern string, obj interface{}, method string) + func (d *Domain) BindObjectRest(pattern string, obj interface{}) + func (d *Domain) BindStatusHandler(status int, handler HandlerFunc) + func (d *Domain) BindStatusHandlerByMap(handlerMap map[int]HandlerFunc) + func (d *Domain) EnablePProf(pattern ...string) + func (d *Domain) Group(prefix string, groups ...func(group *RouterGroup)) *RouterGroup + func (d *Domain) Use(handlers ...HandlerFunc) + type HandlerFunc = func(r *Request) + func WrapF(f http.HandlerFunc) HandlerFunc + func WrapH(h http.Handler) HandlerFunc + type HandlerItem struct + HookName string + Id int + Info handlerFuncInfo + InitFunc HandlerFunc + Middleware []HandlerFunc + Name string + Router *Router + ShutFunc HandlerFunc + Source string + Type string + func (item HandlerItem) MarshalJSON() ([]byte, error) + type HandlerItemParsed struct + Handler *HandlerItem + Values map[string]string + func (item HandlerItemParsed) MarshalJSON() ([]byte, error) + type Plugin interface + Author func() string + Description func() string + Install func(s *Server) error + Name func() string + Remove func() error + Version func() string + type Request struct + Cookie *Cookie + EnterTime int64 + LeaveTime int64 + Middleware *middleware + Response *Response + Router *Router + Server *Server + Session *gsession.Session + StaticFile *staticFile + func RequestFromCtx(ctx context.Context) *Request + func (r *Request) Assign(key string, value interface{}) + func (r *Request) Assigns(data gview.Params) + func (r *Request) BasicAuth(user, pass string, tips ...string) bool + func (r *Request) Context() context.Context + func (r *Request) Exit() + func (r *Request) ExitAll() + func (r *Request) ExitHook() + func (r *Request) Get(key string, def ...interface{}) *gvar.Var + func (r *Request) GetBody() []byte + func (r *Request) GetBodyString() string + func (r *Request) GetClientIp() string + func (r *Request) GetCtx() context.Context + func (r *Request) GetCtxVar(key interface{}, def ...interface{}) *gvar.Var + func (r *Request) GetError() error + func (r *Request) GetForm(key string, def ...interface{}) *gvar.Var + func (r *Request) GetFormMap(kvMap ...map[string]interface{}) map[string]interface{} + func (r *Request) GetFormMapStrStr(kvMap ...map[string]interface{}) map[string]string + func (r *Request) GetFormMapStrVar(kvMap ...map[string]interface{}) map[string]*gvar.Var + func (r *Request) GetFormStruct(pointer interface{}, mapping ...map[string]string) error + func (r *Request) GetHandlerResponse() interface{} + func (r *Request) GetHeader(key string) string + func (r *Request) GetHost() string + func (r *Request) GetJson() (*gjson.Json, error) + func (r *Request) GetMap(def ...map[string]interface{}) map[string]interface{} + func (r *Request) GetMapStrStr(def ...map[string]interface{}) map[string]string + func (r *Request) GetMultipartFiles(name string) []*multipart.FileHeader + func (r *Request) GetMultipartForm() *multipart.Form + func (r *Request) GetPage(totalSize, pageSize int) *gpage.Page + func (r *Request) GetParam(key string, def ...interface{}) *gvar.Var + func (r *Request) GetQuery(key string, def ...interface{}) *gvar.Var + func (r *Request) GetQueryMap(kvMap ...map[string]interface{}) map[string]interface{} + func (r *Request) GetQueryMapStrStr(kvMap ...map[string]interface{}) map[string]string + func (r *Request) GetQueryMapStrVar(kvMap ...map[string]interface{}) map[string]*gvar.Var + func (r *Request) GetQueryStruct(pointer interface{}, mapping ...map[string]string) error + func (r *Request) GetReferer() string + func (r *Request) GetRemoteIp() string + func (r *Request) GetRequest(key string, def ...interface{}) *gvar.Var + func (r *Request) GetRequestMap(kvMap ...map[string]interface{}) map[string]interface{} + func (r *Request) GetRequestMapStrStr(kvMap ...map[string]interface{}) map[string]string + func (r *Request) GetRequestMapStrVar(kvMap ...map[string]interface{}) map[string]*gvar.Var + func (r *Request) GetRequestStruct(pointer interface{}, mapping ...map[string]string) error + func (r *Request) GetRouter(key string, def ...interface{}) *gvar.Var + func (r *Request) GetRouterMap() map[string]string + func (r *Request) GetServeHandler() *HandlerItemParsed + func (r *Request) GetSessionId() string + func (r *Request) GetStruct(pointer interface{}, mapping ...map[string]string) error + func (r *Request) GetUploadFile(name string) *UploadFile + func (r *Request) GetUploadFiles(name string) UploadFiles + func (r *Request) GetUrl() string + func (r *Request) GetView() *gview.View + func (r *Request) IsAjaxRequest() bool + func (r *Request) IsExited() bool + func (r *Request) IsFileRequest() bool + func (r *Request) Parse(pointer interface{}) error + func (r *Request) ParseForm(pointer interface{}) error + func (r *Request) ParseQuery(pointer interface{}) error + func (r *Request) ReloadParam() + func (r *Request) SetCtx(ctx context.Context) + func (r *Request) SetCtxVar(key interface{}, value interface{}) + func (r *Request) SetError(err error) + func (r *Request) SetForm(key string, value interface{}) + func (r *Request) SetParam(key string, value interface{}) + func (r *Request) SetParamMap(data map[string]interface{}) + func (r *Request) SetQuery(key string, value interface{}) + func (r *Request) SetView(view *gview.View) + func (r *Request) WebSocket() (*WebSocket, error) + type Response struct + Request *Request + Server *Server + Writer *ResponseWriter + func (r *Response) Buffer() []byte + func (r *Response) BufferLength() int + func (r *Response) BufferString() string + func (r *Response) CORS(options CORSOptions) + func (r *Response) CORSAllowedOrigin(options CORSOptions) bool + func (r *Response) CORSDefault() + func (r *Response) ClearBuffer() + func (r *Response) DefaultCORSOptions() CORSOptions + func (r *Response) Flush() + func (r *Response) ParseTpl(tpl string, params ...gview.Params) (string, error) + func (r *Response) ParseTplContent(content string, params ...gview.Params) (string, error) + func (r *Response) ParseTplDefault(params ...gview.Params) (string, error) + func (r *Response) RedirectBack(code ...int) + func (r *Response) RedirectTo(location string, code ...int) + func (r *Response) ServeContent(name string, modTime time.Time, content io.ReadSeeker) + func (r *Response) ServeFile(path string, allowIndex ...bool) + func (r *Response) ServeFileDownload(path string, name ...string) + func (r *Response) SetBuffer(data []byte) + func (r *Response) Write(content ...interface{}) + func (r *Response) WriteExit(content ...interface{}) + func (r *Response) WriteJson(content interface{}) + func (r *Response) WriteJsonExit(content interface{}) + func (r *Response) WriteJsonP(content interface{}) + func (r *Response) WriteJsonPExit(content interface{}) + func (r *Response) WriteOver(content ...interface{}) + func (r *Response) WriteOverExit(content ...interface{}) + func (r *Response) WriteStatus(status int, content ...interface{}) + func (r *Response) WriteStatusExit(status int, content ...interface{}) + func (r *Response) WriteTpl(tpl string, params ...gview.Params) error + func (r *Response) WriteTplContent(content string, params ...gview.Params) error + func (r *Response) WriteTplDefault(params ...gview.Params) error + func (r *Response) WriteXml(content interface{}, rootTag ...string) + func (r *Response) WriteXmlExit(content interface{}, rootTag ...string) + func (r *Response) Writef(format string, params ...interface{}) + func (r *Response) WritefExit(format string, params ...interface{}) + func (r *Response) Writefln(format string, params ...interface{}) + func (r *Response) WriteflnExit(format string, params ...interface{}) + func (r *Response) Writeln(content ...interface{}) + func (r *Response) WritelnExit(content ...interface{}) + type ResponseWriter struct + Status int + func (w *ResponseWriter) Flush() + func (w *ResponseWriter) Header() http.Header + func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) + func (w *ResponseWriter) RawWriter() http.ResponseWriter + func (w *ResponseWriter) Write(data []byte) (int, error) + func (w *ResponseWriter) WriteHeader(status int) + type Router struct + Domain string + Method string + Priority int + RegNames []string + RegRule string + Uri string + type RouterGroup struct + func (g *RouterGroup) ALL(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) ALLMap(m map[string]interface{}) + func (g *RouterGroup) Bind(handlerOrObject ...interface{}) *RouterGroup + func (g *RouterGroup) CONNECT(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) Clone() *RouterGroup + func (g *RouterGroup) DELETE(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) GET(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) Group(prefix string, groups ...func(group *RouterGroup)) *RouterGroup + func (g *RouterGroup) HEAD(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) Hook(pattern string, hook string, handler HandlerFunc) *RouterGroup + func (g *RouterGroup) Map(m map[string]interface{}) + func (g *RouterGroup) Middleware(handlers ...HandlerFunc) *RouterGroup + func (g *RouterGroup) OPTIONS(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) PATCH(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) POST(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) PUT(pattern string, object interface{}, params ...interface{}) *RouterGroup + func (g *RouterGroup) REST(pattern string, object interface{}) *RouterGroup + func (g *RouterGroup) TRACE(pattern string, object interface{}, params ...interface{}) *RouterGroup + type RouterItem struct + Address string + Domain string + Handler *HandlerItem + IsServiceHandler bool + Method string + Middleware string + Priority int + Route string + Server string + Type string + type Server struct + func GetServer(name ...interface{}) *Server + func (s *Server) AddSearchPath(path string) + func (s *Server) AddStaticPath(prefix string, path string) + func (s *Server) BindHandler(pattern string, handler interface{}) + func (s *Server) BindHookHandler(pattern string, hook string, handler HandlerFunc) + func (s *Server) BindHookHandlerByMap(pattern string, hookMap map[string]HandlerFunc) + func (s *Server) BindMiddleware(pattern string, handlers ...HandlerFunc) + func (s *Server) BindMiddlewareDefault(handlers ...HandlerFunc) + func (s *Server) BindObject(pattern string, object interface{}, method ...string) + func (s *Server) BindObjectMethod(pattern string, object interface{}, method string) + func (s *Server) BindObjectRest(pattern string, object interface{}) + func (s *Server) BindStatusHandler(status int, handler HandlerFunc) + func (s *Server) BindStatusHandlerByMap(handlerMap map[int]HandlerFunc) + func (s *Server) Domain(domains string) *Domain + func (s *Server) EnableAdmin(pattern ...string) + func (s *Server) EnableHTTPS(certFile, keyFile string, tlsConfig ...*tls.Config) + func (s *Server) EnablePProf(pattern ...string) + func (s *Server) GetCookieDomain() string + func (s *Server) GetCookieHttpOnly() bool + func (s *Server) GetCookieMaxAge() time.Duration + func (s *Server) GetCookiePath() string + func (s *Server) GetCookieSameSite() http.SameSite + func (s *Server) GetCookieSecure() bool + func (s *Server) GetHandler() func(w http.ResponseWriter, r *http.Request) + func (s *Server) GetIndexFiles() []string + func (s *Server) GetListenedAddress() string + func (s *Server) GetListenedPort() int + func (s *Server) GetListenedPorts() []int + func (s *Server) GetLogPath() string + func (s *Server) GetName() string + func (s *Server) GetOpenApi() *goai.OpenApiV3 + func (s *Server) GetRegistrar() gsvc.Registrar + func (s *Server) GetRoutes() []RouterItem + func (s *Server) GetSessionCookieMaxAge() time.Duration + func (s *Server) GetSessionIdName() string + func (s *Server) GetSessionMaxAge() time.Duration + func (s *Server) Group(prefix string, groups ...func(group *RouterGroup)) *RouterGroup + func (s *Server) IsAccessLogEnabled() bool + func (s *Server) IsErrorLogEnabled() bool + func (s *Server) Logger() *glog.Logger + func (s *Server) Plugin(plugin ...Plugin) + func (s *Server) Run() + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (s *Server) SetAccessLogEnabled(enabled bool) + func (s *Server) SetAddr(address string) + func (s *Server) SetClientMaxBodySize(maxSize int64) + func (s *Server) SetConfig(c ServerConfig) error + func (s *Server) SetConfigWithMap(m map[string]interface{}) error + func (s *Server) SetCookieDomain(domain string) + func (s *Server) SetCookieMaxAge(ttl time.Duration) + func (s *Server) SetCookiePath(path string) + func (s *Server) SetDumpRouterMap(enabled bool) + func (s *Server) SetErrorLogEnabled(enabled bool) + func (s *Server) SetErrorStack(enabled bool) + func (s *Server) SetFileServerEnabled(enabled bool) + func (s *Server) SetFormParsingMemory(maxMemory int64) + func (s *Server) SetHTTPSAddr(address string) + func (s *Server) SetHTTPSPort(port ...int) + func (s *Server) SetHandler(h func(w http.ResponseWriter, r *http.Request)) + func (s *Server) SetIdleTimeout(t time.Duration) + func (s *Server) SetIndexFiles(indexFiles []string) + func (s *Server) SetIndexFolder(enabled bool) + func (s *Server) SetKeepAlive(enabled bool) + func (s *Server) SetListener(listeners ...net.Listener) error + func (s *Server) SetLogLevel(level string) + func (s *Server) SetLogPath(path string) error + func (s *Server) SetLogStdout(enabled bool) + func (s *Server) SetLogger(logger *glog.Logger) + func (s *Server) SetMaxHeaderBytes(b int) + func (s *Server) SetName(name string) + func (s *Server) SetNameToUriType(t int) + func (s *Server) SetOpenApiPath(path string) + func (s *Server) SetPort(port ...int) + func (s *Server) SetReadTimeout(t time.Duration) + func (s *Server) SetRegistrar(registrar gsvc.Registrar) + func (s *Server) SetRewrite(uri string, rewrite string) + func (s *Server) SetRewriteMap(rewrites map[string]string) + func (s *Server) SetRouteOverWrite(enabled bool) + func (s *Server) SetServerAgent(agent string) + func (s *Server) SetServerRoot(root string) + func (s *Server) SetSessionCookieMaxAge(maxAge time.Duration) + func (s *Server) SetSessionCookieOutput(enabled bool) + func (s *Server) SetSessionIdName(name string) + func (s *Server) SetSessionMaxAge(ttl time.Duration) + func (s *Server) SetSessionStorage(storage gsession.Storage) + func (s *Server) SetSwaggerPath(path string) + func (s *Server) SetTLSConfig(tlsConfig *tls.Config) + func (s *Server) SetView(view *gview.View) + func (s *Server) SetWriteTimeout(t time.Duration) + func (s *Server) Shutdown() error + func (s *Server) Start() error + func (s *Server) Status() int + func (s *Server) Use(handlers ...HandlerFunc) + type ServerConfig struct + AccessLogEnabled bool + AccessLogPattern string + Address string + ClientMaxBodySize int64 + CookieDomain string + CookieHttpOnly bool + CookieMaxAge time.Duration + CookiePath string + CookieSameSite string + CookieSecure bool + DumpRouterMap bool + ErrorLogEnabled bool + ErrorLogPattern string + ErrorStack bool + FileServerEnabled bool + FormParsingMemory int64 + Graceful bool + GracefulTimeout uint8 + HTTPSAddr string + HTTPSCertPath string + HTTPSKeyPath string + Handler func(w http.ResponseWriter, r *http.Request) + IdleTimeout time.Duration + IndexFiles []string + IndexFolder bool + KeepAlive bool + Listeners []net.Listener + LogLevel string + LogPath string + LogStdout bool + Logger *glog.Logger + MaxHeaderBytes int + Name string + NameToUriType int + OpenApiPath string + PProfEnabled bool + PProfPattern string + ReadTimeout time.Duration + Rewrites map[string]string + RouteOverWrite bool + SearchPaths []string + ServerAgent string + ServerRoot string + SessionCookieMaxAge time.Duration + SessionCookieOutput bool + SessionIdName string + SessionMaxAge time.Duration + SessionPath string + SessionStorage gsession.Storage + StaticPaths []staticPathItem + SwaggerPath string + TLSConfig *tls.Config + View *gview.View + WriteTimeout time.Duration + func ConfigFromMap(m map[string]interface{}) (ServerConfig, error) + func NewConfig() ServerConfig + type Session = gsession.Session + type UploadFile struct + func (f *UploadFile) Save(dirPath string, randomlyRename ...bool) (filename string, err error) + func (f UploadFile) MarshalJSON() ([]byte, error) + type UploadFiles []*UploadFile + func (fs UploadFiles) Save(dirPath string, randomlyRename ...bool) (filenames []string, err error) + type WebSocket struct