Documentation
¶
Overview ¶
leafveingo config handle web request context controller handle error info manager Leafveingo web framework web form params pack struct response body result out router manager
web status page manager
golang system some private functions implement
Index ¶
- Constants
- Variables
- func AddRouter(appName string, router IRouter)
- func BodyJson(value interface{}) SFJson.Json
- func BodyTemplate(data interface{}) LVTemplate.TemplateValue
- func BodyTemplateByTplName(tplName string, data interface{}) LVTemplate.TemplateValue
- func BodyTemplateByTplPath(tplPath string, data interface{}) LVTemplate.TemplateValue
- func BodyText(text string) string
- func Close()
- func SetLogManager(channelSize int)
- func Start()
- func StatusCodeToString(status HttpStatus) string
- func StatusMsg(status HttpStatus) string
- func Version() string
- type AdeRouterController
- type BeforeAfterController
- type ByteOut
- type Config
- type ControllerOption
- type Dispatcher
- type HtmlOut
- type HttpContext
- func (ctx *HttpContext) Application() *SFHelper.Map
- func (ctx *HttpContext) CheckFormToken() bool
- func (ctx *HttpContext) CheckFormTokenByString(token string) bool
- func (ctx *HttpContext) ComperssWriter() io.Writer
- func (ctx *HttpContext) FormTokenHTML() string
- func (ctx *HttpContext) FormTokenJavascript() string
- func (ctx *HttpContext) FormTokenString() string
- func (ctx *HttpContext) FuncNames() []string
- func (ctx *HttpContext) GetIRouter(routerKey string) (IRouter, bool)
- func (ctx *HttpContext) LVServer() *LeafveinServer
- func (ctx *HttpContext) PackStructForm(nilStruct interface{}) (ptrStruct interface{}, err error)
- func (ctx *HttpContext) PackStructFormByRefType(structType reflect.Type) (refVal reflect.Value, err error)
- func (ctx *HttpContext) RequestBody() []byte
- func (ctx *HttpContext) RequestHost() string
- func (ctx *HttpContext) RequestScheme() URIScheme
- func (ctx *HttpContext) RespBodyWrite(body []byte, code HttpStatus)
- func (ctx *HttpContext) RespBodyWriteNotComperss(body []byte, code HttpStatus)
- func (ctx *HttpContext) RouterKeys() []string
- func (ctx *HttpContext) Session(resetToken bool) (LVSession.HttpSession, error)
- func (ctx *HttpContext) StatusPageWrite(status HttpStatus, msg, error, stack string) error
- func (ctx *HttpContext) StatusPageWriteByValue(value HttpStatusValue) error
- type HttpStatus
- type HttpStatusValue
- type IRouter
- type LeafveinError
- type LeafveinServer
- func (lv *LeafveinServer) AddCacheTemplate(tplName, src string) error
- func (lv *LeafveinServer) AddRouter(router IRouter)
- func (lv *LeafveinServer) AddTemplateFunc(key string, methodFunc interface{})
- func (lv *LeafveinServer) Addr() string
- func (lv *LeafveinServer) AppName() string
- func (lv *LeafveinServer) AppVersion() string
- func (lv *LeafveinServer) Application() *SFHelper.Map
- func (lv *LeafveinServer) Charset() string
- func (lv *LeafveinServer) Close()
- func (lv *LeafveinServer) FileUploadSize() int64
- func (lv *LeafveinServer) GetHandlerFunc(prefix string) (handler http.Handler, err error)
- func (lv *LeafveinServer) HttpSessionManager() *LVSession.HttpSessionManager
- func (lv *LeafveinServer) IsCompactHTML() bool
- func (lv *LeafveinServer) IsDevel() bool
- func (lv *LeafveinServer) IsReqPathIgnoreCase() bool
- func (lv *LeafveinServer) IsRespWriteCompress() bool
- func (lv *LeafveinServer) IsStart() bool
- func (lv *LeafveinServer) Log() *SFLog.SFLogger
- func (lv *LeafveinServer) LogConfPath() string
- func (lv *LeafveinServer) LogGroup() string
- func (lv *LeafveinServer) MultiProjectHosts() []string
- func (lv *LeafveinServer) OperatingDir() string
- func (lv *LeafveinServer) Port() int
- func (lv *LeafveinServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (lv *LeafveinServer) ServerTimeout() int64
- func (lv *LeafveinServer) SessionMaxlifeTime() int32
- func (lv *LeafveinServer) SetAppVersion(version string)
- func (lv *LeafveinServer) SetCharset(encode string)
- func (lv *LeafveinServer) SetCompactHTML(compact bool)
- func (l *LeafveinServer) SetCorrectRequestFunc(f func(req *http.Request))
- func (lv *LeafveinServer) SetFileUploadSize(maxSize int64)
- func (lv *LeafveinServer) SetHttpSessionManager(sessionManager *LVSession.HttpSessionManager)
- func (lv *LeafveinServer) SetHttpTLS(cretpath, keypath string, port int, aloneRun bool)
- func (lv *LeafveinServer) SetIPHeaderKey(key string)
- func (lv *LeafveinServer) SetLogConfigPath(path string)
- func (lv *LeafveinServer) SetLogGroup(groupName string)
- func (lv *LeafveinServer) SetMultiProjectHosts(hosts ...string)
- func (lv *LeafveinServer) SetReqPathIgnoreCase(ignoreCase bool)
- func (lv *LeafveinServer) SetRespWriteCompress(b bool)
- func (lv *LeafveinServer) SetServerTimeout(seconds int64)
- func (lv *LeafveinServer) SetSessionMaxlifeTime(second int32)
- func (lv *LeafveinServer) SetStaticFileSuffixes(suffixes ...string)
- func (lv *LeafveinServer) SetTemplateSuffix(suffix string)
- func (lv *LeafveinServer) Start(goroutine bool)
- func (lv *LeafveinServer) StaticFileSuffixes() []string
- func (lv *LeafveinServer) TLSCertPath() string
- func (lv *LeafveinServer) TLSKeyPath() string
- func (lv *LeafveinServer) TLSPort() int
- func (lv *LeafveinServer) TemplateDir() string
- func (lv *LeafveinServer) TemplateSuffix() string
- func (lv *LeafveinServer) TestStart() bool
- func (lv *LeafveinServer) UserData(key string) string
- func (lv *LeafveinServer) WebRootDir() string
- type Redirect
- type RouterElement
- type RouterOption
- type ServeFilePath
- type ServerOption
- type URIScheme
Constants ¶
View Source
const ( // default web root dir name DEFAULT_WEBROOT_DIR_NAME = "webRoot" // default template dir name DEFAULT_TEMPLATE_DIR_NAME = "template" // file size default upload 32M DEFAULT_FILE_UPLOAD_SIZE int64 = 32 << 20 // server time out default 0 DEFAULT_SERVER_TIMEOUT = 0 // default template suffix DEFAULT_TEMPLATE_SUFFIX = ".tpl" // default html charset DEFAULT_HTML_CHARSET = "utf-8" // default response write compress DEFAULT_RESPONSE_WRITE_COMPRESS = true // default session max life time 1800 seconds DEFAULT_SESSION_MAX_LIFE_TIME = 1800 // default log channel size DEFAULT_LOG_CHANNEL_SIZE = 5000 // default KeepAlivePeriod DEFAULT_KEEP_ALIVE_PERIOD = 3 * time.Minute )
View Source
const ( // leafveingo version VERSION string = "0.0.2.000" // template func key TEMPLATE_FUNC_KEY_VERSION = "Leafveingo_version" TEMPLATE_FUNC_KEY_APP_VERSION = "Leafveingo_app_version" TEMPLATE_FUNC_KEY_APP_NAME = "Leafveingo_app_name" TEMPLATE_FUNC_KEY_IS_DEVEL = "Leafveingo_devel" // 不知道为什么golang使用http.ServeFile判断为此结尾就重定向到/index.html中。 // 这里定义主要用来解决这个问题的处理 INDEX_PAGE = "/index.html" // FAVICON_PATH = "/favicon.ico" // url params host key URL_HOST_KEY = "host" // hosts www URL_HOST_WWW = "www." URL_HOST_WWW_LEN = 4 // uri schemes URI_SCHEME_HTTP = URIScheme(1) // http URI_SCHEME_HTTPS = URIScheme(2) // https )
View Source
const ( HttpStartTemplate = `` /* 1314-byte string literal not displayed */ Status301Msg = "Moved Permanently" Status302Msg = "Moved Temporarily" Status307Msg = "Temporary Redirect" Status400Msg = "Bad Request" Status403Msg = "Forbidden The server understood the request" Status404Msg = "Page Not Found" Status500Msg = "Internal Server Error" Status503Msg = "Service Unavailable" )
View Source
const (
HTML_FORM_TOKEN_NAME = "formToken"
)
Variables ¶
View Source
var ( // controller reflect type RefTypeBeforeAfterController = reflect.TypeOf((*BeforeAfterController)(nil)).Elem() RefTypeAdeRouterController = reflect.TypeOf((*AdeRouterController)(nil)).Elem() )
View Source
var ( // http session manager close status ErrHttpSessionManagerClosed = NewLeafveinError("HttpSession manager has been closed or not started.") ErrControllerReturnParam = NewLeafveinError("controllers return type parameter error.") ErrControllerReturnParamNum = NewLeafveinError("controller returns the number of type parameters allowed only one.") // 转发找不到控制器 ErrControllerDispatcherNotFound = NewLeafveinError("dispatcher: controller not found.") ErrControllerDispatcherFuncNameNil = NewLeafveinError("dispatcher: func name is nil.") // Leafvein app name repeat ErrLeafveinAppNameRepeat = NewLeafveinError("Leafvein server app name repeat.") // Leafveingo 配置对象未初始化 ErrLeafveinInitLoadConfig = NewLeafveinError("Leafvein initialized load config error.") ErrLeafveinLoadDefaultConfig = NewLeafveinError("Leafvein load default config error.") // host nil ErrLeafveinSetHostNil = NewLeafveinError("Leafvein set host len()==0 or nil.") // template path pase is nil ErrTemplatePathParseNil = NewLeafveinError("template path parse is nil.") // form params ErrParampackParseFormParams = NewLeafveinError("form params parse error.") ErrParampackNewStruct = NewLeafveinError("form params new struct error.") )
View Source
var ( // http status support code // http://zh.wikipedia.org/wiki/HTTP%E7%8A%B6%E6%80%81%E7%A0%81 Status200 = HttpStatus(200) Status301 = HttpStatus(301) Status302 = HttpStatus(302) Status307 = HttpStatus(307) Status400 = HttpStatus(400) Status403 = HttpStatus(403) Status404 = HttpStatus(404) Status500 = HttpStatus(500) Status503 = HttpStatus(503) StatusNil = HttpStatus(-100) )
View Source
var ( // 开发模式命令 FlagDeveloper bool )
Functions ¶
func BodyTemplate ¶
func BodyTemplate(data interface{}) LVTemplate.TemplateValue
*
- by template out html, text/html *
- default template path by IRouter interface implementation definition *
- @param data
- @return TemplateValue
func BodyTemplateByTplName ¶
func BodyTemplateByTplName(tplName string, data interface{}) LVTemplate.TemplateValue
*
- by cache template name out content *
- @param tplName
- @param data
- @return TemplateValue
func BodyTemplateByTplPath ¶
func BodyTemplateByTplPath(tplPath string, data interface{}) LVTemplate.TemplateValue
*
- by template out content
- custom template path: (templateDir)/(tplPath).tpl
- e.g.: tplPath = "custom/base.tpl"
- templatePath = (templateDir)/custom/base.tpl *
- @param tplPath custom template path
- @param data
- @return TemplateValue
func SetLogManager ¶
func SetLogManager(channelSize int)
func StatusCodeToString ¶
func StatusCodeToString(status HttpStatus) string
*
- status code convert string *
- @param status
- @return
Types ¶
type AdeRouterController ¶
type AdeRouterController interface { /** * 路由函数解析,解析工作完全交由现实对象进行。 * * @param option router params option * @return funcName is "" jump 404 page, other by name call controller * @return params add to request form param, use set Request.URL.Query() */ RouterMethodParse(option *RouterOption) (funcName string, params map[string]string) }
高级路由器控制器接口,实现高级路由器机制的控制器需要实现该接口 特别注意,指针添加控制器和值添加的控制器的实现区别 指针控制器的实现: func (c *XxxController) RouterMethodParse...
值控制器的实现:func (c XxxController) RouterMethodParse...
type BeforeAfterController ¶
type BeforeAfterController interface { /** * before the call controller func * * @param context * @param option * @return Status200 pass, StatusNil stop Next to proceed, other status jump relevant status page * */ Before(context *HttpContext, option *RouterOption) HttpStatus /** * after the call controller func * * @param context * @param option */ After(context *HttpContext, option *RouterOption) }
before after interface
type ByteOut ¶
type ByteOut struct { Body []byte // out content ContentType string // content type "text/plain; charset=utf-8" || "image/png" ... Headers map[string]string // 可以为空,看是否需要设置其他头部信息 }
body out
type Config ¶
type Config struct { AppVersion string // app version. FileUploadSize int64 // file size upload Charset string // html encode type StaticFileSuffixes []string // supported static file suffixes ServerTimeout int64 // server time out, default 0 SessionMaxlifeTime int32 // http session maxlife time, unit second. use session set IPHeaderKey string // proxy to http headers set ip key, default "" IsReqPathIgnoreCase bool // request url path ignore case MultiProjectHosts []string // setting integrated multi-project hosts,default nil TemplateSuffix string // template suffix IsCompactHTML bool // is Compact HTML, default true LogConfigPath string // log config path, relative or absolute path, relative path from execute file root directory LogGroup string // log group name TLSCertPath string // tls cert.pem, relative or absolute path, relative path from execute file root directory TLSKeyPath string // tls key.pem TLSPort int // tls run prot, default server port+1 TLSAloneRun bool // are leafveingo alone run tls server, default false // is ResponseWriter writer compress gizp... // According Accept-Encoding select compress type // default true IsRespWriteCompress bool UserData map[string]string // user custom config other info }
*
- leafveingo config
- default see _defaultConfigJson
type ControllerOption ¶
type ControllerOption struct {
// contains filtered or unexported fields
}
func (*ControllerOption) SetHost ¶
func (c *ControllerOption) SetHost(host string)
*
- set host
- "svn.slowfei.com" || "wwww.slowfei.com" || ""(wildcard)
func (*ControllerOption) SetScheme ¶
func (c *ControllerOption) SetScheme(scheme URIScheme)
*
- set the support scheme *
- URI_SCHEME_HTTPS | URI_SCHEME_HTTP
type Dispatcher ¶
dispatcher controller struct
func BodyCallController ¶
func BodyCallController(routerKey, funcName string) Dispatcher
*
- dispatcher controller *
- @param routerKey router key
- @param funcName controller call func name
- @return Dispatcher
func BodyCallControllerByHeaders ¶
func BodyCallControllerByHeaders(routerKey, funcName string, setHeaders map[string]string) Dispatcher
*
- dispatcher controller, set headers info *
- @param routerKey router key
- @param funcName controller call func name
- @param setHeaders header info
- @return Dispatcher
type HttpContext ¶
type HttpContext struct { RespWrite http.ResponseWriter Request *http.Request // contains filtered or unexported fields }
request context
func (*HttpContext) Application ¶
func (ctx *HttpContext) Application() *SFHelper.Map
*
- get global info storage map *
- @return SFHelper.Map
func (*HttpContext) CheckFormToken ¶
func (ctx *HttpContext) CheckFormToken() bool
*
- check form token *
- @return true is pass
func (*HttpContext) CheckFormTokenByString ¶
func (ctx *HttpContext) CheckFormTokenByString(token string) bool
*
- custom check form token *
- @param true is pass
func (*HttpContext) ComperssWriter ¶
func (ctx *HttpContext) ComperssWriter() io.Writer
*
- get comperss writer *
- @return
func (*HttpContext) FormTokenHTML ¶
func (ctx *HttpContext) FormTokenHTML() string
*
- get html input form token
- Note: each access will change *
- @return
func (*HttpContext) FormTokenJavascript ¶
func (ctx *HttpContext) FormTokenJavascript() string
*
- get javascript the out form token, (主要防止页面抓取)
- Note: each access will change *
- @return
func (*HttpContext) FormTokenString ¶
func (ctx *HttpContext) FormTokenString() string
*
- get string form token
- Note: each access will change *
- @return
func (*HttpContext) FuncNames ¶
func (ctx *HttpContext) FuncNames() []string
*
- request controller methods *
- @return
func (*HttpContext) GetIRouter ¶
func (ctx *HttpContext) GetIRouter(routerKey string) (IRouter, bool)
*
- get router list element *
- @return *RouterElement
func (*HttpContext) LVServer ¶
func (ctx *HttpContext) LVServer() *LeafveinServer
*
- get current leafvein server *
- @return *LeafveinServer
func (*HttpContext) PackStructForm ¶
func (ctx *HttpContext) PackStructForm(nilStruct interface{}) (ptrStruct interface{}, err error)
*
- pack stauct form params *
- @param nilStruct (*TestStruct)(nil)
- @return new pointer struct by Type
func (*HttpContext) PackStructFormByRefType ¶
func (ctx *HttpContext) PackStructFormByRefType(structType reflect.Type) (refVal reflect.Value, err error)
*
- pack stauct form params by reflect type *
- @param structType
- @return refVal
- @return err
func (*HttpContext) RequestBody ¶
func (ctx *HttpContext) RequestBody() []byte
*
- get request body content *
- @return
func (*HttpContext) RequestHost ¶
func (ctx *HttpContext) RequestHost() string
*
- request host *
- @return lowercase string
func (*HttpContext) RequestScheme ¶
func (ctx *HttpContext) RequestScheme() URIScheme
*
- request uri scheme *
- @return URIScheme
func (*HttpContext) RespBodyWrite ¶
func (ctx *HttpContext) RespBodyWrite(body []byte, code HttpStatus)
*
- response comperss write
- 会根据Accept-Encoding支持的格式进行压缩,优先gzip *
- @param body write content
- @param code status code
func (*HttpContext) RespBodyWriteNotComperss ¶
func (ctx *HttpContext) RespBodyWriteNotComperss(body []byte, code HttpStatus)
*
- response not comperss write Content-Encoding = none *
- @param body
- @param code
func (*HttpContext) RouterKeys ¶
func (ctx *HttpContext) RouterKeys() []string
*
- requset router keys *
- @return
func (*HttpContext) Session ¶
func (ctx *HttpContext) Session(resetToken bool) (LVSession.HttpSession, error)
*
- get session, context the only session *
- @param resetToken is reset session token
- @return HttpSession
- @return error
func (*HttpContext) StatusPageWrite ¶
func (ctx *HttpContext) StatusPageWrite(status HttpStatus, msg, error, stack string) error
*
- status page write
- 指定模版的几个参数值,在模板中信息信息的输出
- 模版的默认map key: {{.msg}} {{.status}} {{.error}} {{.stack}} *
- @param status status code
- @param msg
- @param error
- @param stack
- @return
func (*HttpContext) StatusPageWriteByValue ¶
func (ctx *HttpContext) StatusPageWriteByValue(value HttpStatusValue) error
*
- status page write
- 可以自定义指定模版的参数 *
- @param value
- @return
type HttpStatusValue ¶
type HttpStatusValue struct {
// contains filtered or unexported fields
}
数据的封装
func BodyStatusPage ¶
func BodyStatusPage(status HttpStatus, msg, error, stack string) HttpStatusValue
*
- out status page *
- @param status Status404...
- @param msg
- @param error
- @param stack
- @return HttpStatusValue
func BodyStatusPageByData ¶
func BodyStatusPageByData(status HttpStatus, data map[string]string) HttpStatusValue
*
- out status pata custom data map *
- @param status
- @param data
- @return HttpStatusValue
func NewHttpStatusValue ¶
func NewHttpStatusValue(status HttpStatus, msg, error, stack string) HttpStatusValue
new status value
type IRouter ¶
type IRouter interface { /** * 1. after router parse * * @param context * @param option * @return HttpStatus 200 pass */ AfterRouterParse(context *HttpContext, option *RouterOption) HttpStatus /** * 2. parse func name * * @param context http context * @param option router option * @return funcName function name specifies call * @return statusCode http status code, 200 pass, other to status page */ ParseFuncName(context *HttpContext, option *RouterOption) (funcName string, statusCode HttpStatus, err error) /** * 3. before call func * * @param context * @param option * @return HttpStatus */ CallFuncBefore(context *HttpContext, option *RouterOption) HttpStatus /** * 4. request func * * @param context http content * @param funcName call controller func name * @param option router option * @return returnValue controller func return value * @return statusCode http status code, 200 pass, other to status page */ CallFunc(context *HttpContext, funcName string, option *RouterOption) (returnValue interface{}, statusCode HttpStatus, err error) /** * 5. parse template path * no need to add the suffix * * @param context * @param funcName controller call func name * @param option router option * @return template path, suggest "[routerKey]/[funcName]" */ ParseTemplatePath(context *HttpContext, funcName string, option *RouterOption) string /** * 6. after call func * * @param context * @param option */ CallFuncAfter(context *HttpContext, option *RouterOption) /** * @return router key */ RouterKey() string /** * @return controller option */ ControllerOption() ControllerOption /** * @return controller info */ Info() string }
router interface
type LeafveinError ¶
leafveingo error
func NewLeafveinError ¶
func NewLeafveinError(format string, args ...interface{}) *LeafveinError
new error info
func (*LeafveinError) Equal ¶
func (err *LeafveinError) Equal(eqErr *LeafveinError) bool
*
- equal error *
- @param
- @return
type LeafveinServer ¶
type LeafveinServer struct {
// contains filtered or unexported fields
}
Leafvein Http Server
func GetServer ¶
func GetServer(appName string) *LeafveinServer
*
- by app name get leafvein server *
- @param appName
- @return
func NewLeafveinServer ¶
func NewLeafveinServer(appName string, option ServerOption) *LeafveinServer
*
- new http server *
- @param appName application name not is null
- @param option server other option
func (*LeafveinServer) AddCacheTemplate ¶
func (lv *LeafveinServer) AddCacheTemplate(tplName, src string) error
*
- add cache template *
- @param tplName template unique name
- @param src template content
- @return error info
func (*LeafveinServer) AddRouter ¶
func (lv *LeafveinServer) AddRouter(router IRouter)
*
- add router
- leafvein interface implement RESTfulRouter ReflectRouter *
- match rules:
- (keys sort of long to short)
- keys =[
- "/admin/user/"
- "/admin/"
- "/user/"
- "/"
- ] *
- e.g.: *
- [urlPath] = [key]; $host = "http://localhost:8080"
- $host/admin/user/manager = "/admin/user/"
- $host/admin/index = "/admin/"
- $host/user/index = "/user/"
- $host/admin = "/"
- $host/index = "/" *
- @param router *
func (*LeafveinServer) AddTemplateFunc ¶
func (lv *LeafveinServer) AddTemplateFunc(key string, methodFunc interface{})
*
- add template function *
- @param `key` the template use func key, please ignore repeated system
- @param `methodFunc`
func (*LeafveinServer) AppName ¶
func (lv *LeafveinServer) AppName() string
*
- get application name *
- @return
func (*LeafveinServer) AppVersion ¶
func (lv *LeafveinServer) AppVersion() string
*
- get application version *
- @return
func (*LeafveinServer) Application ¶
func (lv *LeafveinServer) Application() *SFHelper.Map
*
- web application map *
- @return
func (*LeafveinServer) Charset ¶
func (lv *LeafveinServer) Charset() string
*
- get html encoding type *
- @return
func (*LeafveinServer) Close ¶
func (lv *LeafveinServer) Close()
*
- close Leafvein server *
- TODO Temporarily invalid, keep extension
func (*LeafveinServer) FileUploadSize ¶
func (lv *LeafveinServer) FileUploadSize() int64
*
- get file size upload *
- @return
func (*LeafveinServer) GetHandlerFunc ¶
func (lv *LeafveinServer) GetHandlerFunc(prefix string) (handler http.Handler, err error)
*
- 获取leafveingo的一个Handler, 方便在其他应用进行扩展leafveingo
- get leafveingo handler, Easily be extended to other applications *
- @prefix url prefix
func (*LeafveinServer) HttpSessionManager ¶
func (lv *LeafveinServer) HttpSessionManager() *LVSession.HttpSessionManager
*
- http session manager
func (*LeafveinServer) IsCompactHTML ¶
func (lv *LeafveinServer) IsCompactHTML() bool
*
- get is compact HTML
func (*LeafveinServer) IsDevel ¶
func (lv *LeafveinServer) IsDevel() bool
*
- developer mode *
- @return true is developer mode
func (*LeafveinServer) IsReqPathIgnoreCase ¶
func (lv *LeafveinServer) IsReqPathIgnoreCase() bool
*
- get is request path ignore case *
- @return
func (*LeafveinServer) IsRespWriteCompress ¶
func (lv *LeafveinServer) IsRespWriteCompress() bool
*
- RespWriteCompress *
- @return
func (*LeafveinServer) Log ¶
func (lv *LeafveinServer) Log() *SFLog.SFLogger
*
- get log object *
- @return
func (*LeafveinServer) LogConfPath ¶
func (lv *LeafveinServer) LogConfPath() string
*
- get log config path
func (*LeafveinServer) LogGroup ¶
func (lv *LeafveinServer) LogGroup() string
*
- get log group name *
- @return
func (*LeafveinServer) MultiProjectHosts ¶
func (lv *LeafveinServer) MultiProjectHosts() []string
*
- get project hosts *
- @return
func (*LeafveinServer) OperatingDir ¶
func (lv *LeafveinServer) OperatingDir() string
*
- current leafveingo the file operation directory
- OperatingDir() path is created based on AppName *
- @return
func (*LeafveinServer) ServeHTTP ¶
func (lv *LeafveinServer) ServeHTTP(rw http.ResponseWriter, req *http.Request)
*
- ServeHTTP *
- @param rw
- @param req
func (*LeafveinServer) ServerTimeout ¶
func (lv *LeafveinServer) ServerTimeout() int64
*
- get server time out *
- @return
func (*LeafveinServer) SessionMaxlifeTime ¶
func (lv *LeafveinServer) SessionMaxlifeTime() int32
*
- get http session maxlife time, unit second
func (*LeafveinServer) SetAppVersion ¶
func (lv *LeafveinServer) SetAppVersion(version string)
*
- set application version *
- @param version
func (*LeafveinServer) SetCharset ¶
func (lv *LeafveinServer) SetCharset(encode string)
*
- set html encoding type *
- @param encode default utf-8
func (*LeafveinServer) SetCompactHTML ¶
func (lv *LeafveinServer) SetCompactHTML(compact bool)
*
- out html is compact remove (\t \n space) sign
- only template file out use *
- Note: need to restart Leafvein Server *
- @param compact default true
func (*LeafveinServer) SetCorrectRequestFunc ¶
func (l *LeafveinServer) SetCorrectRequestFunc(f func(req *http.Request))
*
- 修正Requset的设置函数,由于在使用不同的http代理转发操作时解析的参数可能与golang操作的不符合。
- 所以建立此函数在请求前可根据使用的代理转发进行Request的修改。 *
- @param `f` func(req *http.Request)
func (*LeafveinServer) SetFileUploadSize ¶
func (lv *LeafveinServer) SetFileUploadSize(maxSize int64)
*
- set file size upload *
- @param maxSize default 32M
func (*LeafveinServer) SetHttpSessionManager ¶
func (lv *LeafveinServer) SetHttpSessionManager(sessionManager *LVSession.HttpSessionManager)
*
- custom set session manager *
- @param sessionManager nil == stop use session
func (*LeafveinServer) SetHttpTLS ¶
func (lv *LeafveinServer) SetHttpTLS(cretpath, keypath string, port int, aloneRun bool)
*
- set tls run params cert.pem and key.pem
- Note: need to restart Leafvein Server *
- @param cretpath relative or absolute path, relative path from execute file root directory
- @param keypath
- @param port tls run port
- @param aloneRun true is alone run tls server
func (*LeafveinServer) SetIPHeaderKey ¶
func (lv *LeafveinServer) SetIPHeaderKey(key string)
*
- use reverse proxy set header ip key *
- @param key
func (*LeafveinServer) SetLogConfigPath ¶
func (lv *LeafveinServer) SetLogConfigPath(path string)
*
- set log config path *
- Note: need to restart Leafvein Server *
- @param path relative or absolute path, relative path from execute file root directory
func (*LeafveinServer) SetLogGroup ¶
func (lv *LeafveinServer) SetLogGroup(groupName string)
*
- set log group name *
- Note: need to restart Leafvein Server *
- @param groupName
func (*LeafveinServer) SetMultiProjectHosts ¶
func (lv *LeafveinServer) SetMultiProjectHosts(hosts ...string)
*
- set multi-project hosts access *
- @param hosts "slowfei.com"(www.slwofei.com) || "svn.slowfei.com"
func (*LeafveinServer) SetReqPathIgnoreCase ¶
func (lv *LeafveinServer) SetReqPathIgnoreCase(ignoreCase bool)
*
- set request path ignore case *
- @param ignoreCase default true
func (*LeafveinServer) SetRespWriteCompress ¶
func (lv *LeafveinServer) SetRespWriteCompress(b bool)
*
- is ResponseWriter writer compress gizp...
- According Accept-Encoding select compress type *
- @param b default true
func (*LeafveinServer) SetServerTimeout ¶
func (lv *LeafveinServer) SetServerTimeout(seconds int64)
*
- set server time out *
- Note: need to restart Leafvein Server *
- @param seconds default 0. seconds = 10 = 10s
func (*LeafveinServer) SetSessionMaxlifeTime ¶
func (lv *LeafveinServer) SetSessionMaxlifeTime(second int32)
*
- set http session maxlife time, unit second *
- @param second default 1800 second(30 minute), must be greater than 60 seconds
func (*LeafveinServer) SetStaticFileSuffixes ¶
func (lv *LeafveinServer) SetStaticFileSuffixes(suffixes ...string)
*
- set static resource file suffixes *
- @param suffixes default ".js", ".css", ".png", ".jpg", ".gif", ".ico", ".html"
func (*LeafveinServer) SetTemplateSuffix ¶
func (lv *LeafveinServer) SetTemplateSuffix(suffix string)
*
- set template suffix, *
- @param suffix default ".tpl"
func (*LeafveinServer) Start ¶
func (lv *LeafveinServer) Start(goroutine bool)
*
- start leafvein server *
- @param goroutine true is go func(){ // run serve }(), 关键保留一些操作在主线程来运行, 不知道的可以false
func (*LeafveinServer) StaticFileSuffixes ¶
func (lv *LeafveinServer) StaticFileSuffixes() []string
*
- get static resource file suffixs *
- @return
func (*LeafveinServer) TLSCertPath ¶
func (lv *LeafveinServer) TLSCertPath() string
*
- get tls cert.pem file path *
- @return
func (*LeafveinServer) TLSKeyPath ¶
func (lv *LeafveinServer) TLSKeyPath() string
*
- get tls key.pem file path *
- @return
func (*LeafveinServer) TLSPort ¶
func (lv *LeafveinServer) TLSPort() int
*
- get tls run port *
- @return
func (*LeafveinServer) TemplateDir ¶
func (lv *LeafveinServer) TemplateDir() string
*
- template directory, primary storage template file
- OperatingDir() created under the directory *
- ../sample(AppName)/template
func (*LeafveinServer) TemplateSuffix ¶
func (lv *LeafveinServer) TemplateSuffix() string
*
- get template suffix *
- @return
func (*LeafveinServer) TestStart ¶
func (lv *LeafveinServer) TestStart() bool
*
- testing use *
- @param parse router result
func (*LeafveinServer) UserData ¶
func (lv *LeafveinServer) UserData(key string) string
*
- user custom config other info *
- @param key
- @return
func (*LeafveinServer) WebRootDir ¶
func (lv *LeafveinServer) WebRootDir() string
*
- web directory, can read and write to the directory
- primary storage html, css, js, image, zip the file
- OperatingDir() created under the directory *
- ../sample(AppName)/webRoot
type Redirect ¶
type Redirect struct { URLPath string Code HttpStatus }
redirect url
func BodyRedirectByStatusCode ¶
func BodyRedirectByStatusCode(url string, code HttpStatus) Redirect
*
- redirect url by status code *
- @param url
- @param code
- @return Redirect
type RouterElement ¶
type RouterElement struct {
// contains filtered or unexported fields
}
router element
type RouterOption ¶
type RouterOption struct { RouterData interface{} // custom storage data RouterDataRefVal reflect.Value // reflect value data RouterKey string // RouterPath string // have been converted to lowercase RequestMethod string // lowercase get post ... UrlSuffix string // lowercase AppName string // application name }
router option
type ServeFilePath ¶
type ServeFilePath string
body out file to path
func BodyServeFile ¶
func BodyServeFile(path string) ServeFilePath
*
- out file *
- @param parh WebRootDir() path start
- @return ServeFilePath
type ServerOption ¶
type ServerOption struct { // ip access "127.0.0.1" localhost access // all address access // "192.168.?.?" specify access // default "127.0.0.1" Addr string Port int // ip port. default 8080 SMGCTime int64 // session manager gc operate time. 0 is not run session, minimum 60 second. default 300 ConfigPath string // relative or absolute path, relative path from execute file root directory, can set empty. default "" }
*
- Leafvein Server option *
- use DefaultOption() see default value
func (ServerOption) SetConfigPath ¶
func (s ServerOption) SetConfigPath(path string) ServerOption
*
- set config file path
func (ServerOption) SetSMGCTime ¶
func (s ServerOption) SetSMGCTime(second int64) ServerOption
*
- set session manager operate gc
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
example
|
|
reflect router RESTful router
|
reflect router RESTful router |
leafveingo web http session 的封装 功能简介: session高并发获取 自动清除session session id 可选随机数生成或IPUUID 自动统计session生成数量、删除数量和有效数量 session token
|
leafveingo web http session 的封装 功能简介: session高并发获取 自动清除session session id 可选随机数生成或IPUUID 自动统计session生成数量、删除数量和有效数量 session token |
leafveingo web 模板操作模块 leafveingo web 模板使用函数模块
|
leafveingo web 模板操作模块 leafveingo web 模板使用函数模块 |
Click to show internal directories.
Click to hide internal directories.