Documentation
¶
Index ¶
- Constants
- Variables
- func InitSession(sess_key string, expire_ns, renew_ns time.Duration, conn SessionConnector, ...)
- func LogFilter(ctx *Context)
- func PanicFilter(ctx *Context)
- func SessionFilter(ctx *Context)
- type Action
- type Ajax
- func (json Ajax) ClearErrors()
- func (json Ajax) Error(msg string) string
- func (json Ajax) ErrorIf(err error, msg string) bool
- func (json Ajax) HasError() bool
- func (json Ajax) Info(msg string)
- func (json Ajax) LastError() string
- func (json Ajax) OverwriteInfo(msg string)
- func (json Ajax) TestError(err error, errmsg string) bool
- type Context
- func (ctx *Context) AppendAjax(ajax Ajax)
- func (ctx *Context) AppendBuffer(buff bytes.Buffer)
- func (ctx *Context) AppendBytes(buf []byte)
- func (ctx *Context) AppendMap(any M.SX)
- func (ctx *Context) AppendString(txt string)
- func (ctx *Context) Error(code int, info string)
- func (ctx *Context) Finish()
- func (ctx *Context) FirstPath() string
- func (ctx *Context) Headers() M.SS
- func (ctx *Context) Host() string
- func (ctx *Context) IsAjax() bool
- func (ctx *Context) IsWebMaster() bool
- func (ctx *Context) Log(message string)
- func (ctx *Context) Next() Action
- func (ctx *Context) ParamBool(key string) bool
- func (ctx *Context) ParamInt(key string) int64
- func (ctx *Context) ParamJsonMap(key string) M.SX
- func (ctx *Context) ParamJsonStrArr(key string) []string
- func (ctx *Context) ParamStr(key string) string
- func (ctx *Context) PartialNoDebug(path string, locals M.SX) string
- func (ctx *Context) Posts() *Posts
- func (ctx *Context) Proto() string
- func (ctx *Context) QueryParams() *QueryParams
- func (ctx *Context) Render(path string, locals M.SX)
- func (ctx *Context) RequestDebugStr() string
- func (ctx *Context) RequestHtmlStr() string
- func (ctx *Context) RequestLogStr() string
- func (ctx *Context) RequestURL() string
- func (ctx *Context) UploadedFile(id string) (fileName, ext, contentType string, reader multipart.File)
- type Engine
- func (engine *Engine) LoadLayout()
- func (engine *Engine) Log(message string)
- func (engine *Engine) MinifyAssets()
- func (engine *Engine) SendDebugMail(message string)
- func (engine *Engine) SendMail(mail_id string, bcc []string, subject string, message string)
- func (engine *Engine) SendMailSync(mail_id string, bcc []string, subject string, message string) string
- func (engine *Engine) StartServer(addressPort string)
- func (engine *Engine) Template(key string) *Z.TemplateChain
- type Posts
- func (p *Posts) FromContext(ctx *Context)
- func (p *Posts) GetBool(key string) bool
- func (p *Posts) GetJsonIntArr(key string) []int64
- func (p *Posts) GetJsonMap(key string) M.SX
- func (p *Posts) GetJsonObjArr(key string) []map[string]interface{}
- func (p *Posts) GetJsonStrArr(key string) []string
- func (p *Posts) IsSet(key string) bool
- func (p *Posts) NewlineString() string
- func (p *Posts) String() string
- type QueryParams
- type RequestModel
- type Session
- func (s *Session) HeaderString() string
- func (s *Session) Load(ctx *Context)
- func (s *Session) Login(val M.SX)
- func (s *Session) Logout()
- func (s *Session) NewlineString() string
- func (s *Session) RandomKey()
- func (s *Session) Save(ctx *Context)
- func (s *Session) StateCSRF() string
- func (s *Session) String() string
- func (s *Session) Touch()
- type SessionConnector
- type SmtpConfig
- func (mc *SmtpConfig) Address() string
- func (mc *SmtpConfig) Auth() smtp.Auth
- func (mc *SmtpConfig) From() string
- func (mc *SmtpConfig) SendAttachBCC(bcc []string, subject string, message string, files []string)
- func (mc *SmtpConfig) SendBCC(bcc []string, subject string, message string)
- func (m *SmtpConfig) SendRaw(e *email.Email) error
- func (mc *SmtpConfig) SendSyncAttachBCC(bcc []string, subject string, message string, files []string) string
- func (mc *SmtpConfig) SendSyncBCC(bcc []string, subject string, message string) string
Constants ¶
View Source
const ERROR_DEFAULT_CONTENT = `` /* 2226-byte string literal not displayed */
locals: error_code, error_title, error_detail, project_name, requested_path, webmaster
View Source
const LAYOUT_DEFAULT_CONTENT = `` /* 2286-byte string literal not displayed */
locals: title, project_name, assets, contents, is_superadmin, debug_mode
View Source
const LOG_SUBDIR = `logs/`
View Source
const NS2SEC = 1000 * 1000 * 1000
View Source
const PUBLIC_SUBDIR = `public/`
View Source
const VIEWS_SUBDIR = `views/`
Variables ¶
View Source
var Assets [][2]string // []{{`js css /js /css`,`filename`}, ...}
View Source
var DEFAULT_FILEDIR_PERM = os.FileMode(0755)
View Source
var EXPIRE_SEC int64
View Source
var Errors = map[int]string{
0: `Unknown Error`,
500: `Internal Server Error`,
404: `Page Not Found`,
403: `Forbidden`,
503: `Server is Overloaded`,
}
View Source
var Filters []Action
View Source
var MIME2EXT = map[string]string{
`application/pdf`: `pdf`,
`image/png`: `png`,
`image/jpeg`: `jpg`,
`application/zip`: `zip`,
}
View Source
var Mailers map[string]*SmtpConfig // used in mailer.go
View Source
var RENEW_SEC int64
View Source
var Routes map[string]Action
View Source
var SESS_KEY = `SK`
View Source
var Webmasters M.SS // used in engine.go
View Source
var YOUTUBE_MIME2EXT = map[string]string{
`video/x-flv`: `flv`,
`video/mp4`: `mp4`,
`video/quicktime`: `mov`,
`video/x-msvideo`: `avi`,
`video/x-ms-wmv`: `wmv`,
`video/webm`: `webm`,
`video/3gpp`: `3gp`,
`video/mp2p`: `mpegps`,
`video/mp1s`: `mpegps`,
}
supported by youtube
View Source
var YOUTUBE_MIME_LIST []string
Functions ¶
func InitSession ¶
func InitSession(sess_key string, expire_ns, renew_ns time.Duration, conn SessionConnector, glob SessionConnector)
func PanicFilter ¶
func PanicFilter(ctx *Context)
func SessionFilter ¶
func SessionFilter(ctx *Context)
Types ¶
type Context ¶
type Context struct { *fasthttp.RequestCtx Session *Session Title string Engine *Engine Buffer bytes.Buffer Route string Actions []Action PostCache *Posts NoLayout bool ContentType string // contains filtered or unexported fields }
func (*Context) AppendAjax ¶
func (*Context) IsWebMaster ¶
func (*Context) ParamJsonMap ¶
get url parameter as M.SX
func (*Context) ParamJsonStrArr ¶
get url parameter as []string
func (*Context) PartialNoDebug ¶
func (*Context) QueryParams ¶
func (ctx *Context) QueryParams() *QueryParams
get parsed ?a=b&c=d, this is different from Param*() func
type Engine ¶
type Engine struct { DebugMode bool MultiApp bool // contact if there's bug WebMasterAnchor string // view template cache ViewCache *cmap.CMap // global variables GlobalInt M.SI GlobalStr M.SS GlobalAny M.SX Router *fasthttprouter.Router // project_name Name string // location of the project, will be concatenated with VIEWS_SUBDIR, PUBLIC_SUBDIR BaseDir string PublicDir string // with slash Logger *os.File LogPath string // server creation time CreatedAt time.Time // assets <script and <link as string Assets string }
func (*Engine) LoadLayout ¶
func (engine *Engine) LoadLayout()
type Posts ¶
func (*Posts) FromContext ¶
func (*Posts) GetJsonIntArr ¶
func (*Posts) GetJsonObjArr ¶
func (*Posts) GetJsonStrArr ¶
func (*Posts) NewlineString ¶
type QueryParams ¶
func (*QueryParams) GetFloat ¶
func (p *QueryParams) GetFloat(key string) float64
func (*QueryParams) GetInt ¶
func (p *QueryParams) GetInt(key string) int64
func (*QueryParams) GetStr ¶
func (p *QueryParams) GetStr(key string) string
type RequestModel ¶
type RequestModel struct { Id string Uniq string AppId string Posts *Posts Ajax Ajax DbActor string Actor string Level M.SX Ctx *Context Ok bool Action string }
func NewRequestModel_ById_ByDbActor_ByAjax ¶
func NewRequestModel_ById_ByDbActor_ByAjax(id, db_actor string, ajax Ajax) *RequestModel
func NewRequestModel_ByUniq_ByDbActor_ByAjax ¶
func NewRequestModel_ByUniq_ByDbActor_ByAjax(uniq_id string, db_actor string, ajax Ajax) *RequestModel
func (*RequestModel) IdInt ¶
func (rm *RequestModel) IdInt() int64
func (*RequestModel) IsAjax ¶
func (rm *RequestModel) IsAjax() bool
type Session ¶
func (*Session) HeaderString ¶
func (*Session) NewlineString ¶
type SessionConnector ¶
type SessionConnector interface { // delete key Del(key string) // get remaining lifespan in seconds Expiry(key string) int64 // set string with remaining lifespan in seconds FadeStr(key, val string, ttl int64) // set integer with remaining lifespan in seconds FadeInt(key string, val int64, ttl int64) // set json with remaining lifespan in seconds FadeMSX(key string, val M.SX, ttl int64) // get string GetStr(key string) string // get integer GetInt(key string) int64 // get string GetMSX(key string) M.SX // increment Inc(key string) int64 // increment Dec(key string) int64 // set string SetStr(key, val string) // set integer SetInt(key string, val int64) // set json SetMSX(key string, val M.SX) // set json SetMSS(key string, val M.SS) // get product name, eg: Pg, Sc, My, Rd Product() string Lpush(key string, val string) Rpush(key string, val string) Lrange(key string, first, last int64) []string }
var Globals SessionConnector // from session.go
var Sessions SessionConnector // from session.go
type SmtpConfig ¶
func NewMailer ¶
func NewMailer(user, pass, host string, port int) *SmtpConfig
func (*SmtpConfig) Address ¶
func (mc *SmtpConfig) Address() string
func (*SmtpConfig) Auth ¶
func (mc *SmtpConfig) Auth() smtp.Auth
func (*SmtpConfig) From ¶
func (mc *SmtpConfig) From() string
func (*SmtpConfig) SendAttachBCC ¶
func (mc *SmtpConfig) SendAttachBCC(bcc []string, subject string, message string, files []string)
run sendAttachbcc on another goroutine
func (*SmtpConfig) SendBCC ¶
func (mc *SmtpConfig) SendBCC(bcc []string, subject string, message string)
run sendbcc on another goroutine
func (*SmtpConfig) SendSyncAttachBCC ¶
func (mc *SmtpConfig) SendSyncAttachBCC(bcc []string, subject string, message string, files []string) string
sendbcc synchronous version, returns error message
func (*SmtpConfig) SendSyncBCC ¶
func (mc *SmtpConfig) SendSyncBCC(bcc []string, subject string, message string) string
sendbcc synchronous version, returns error message
Source Files
¶
Click to show internal directories.
Click to hide internal directories.