beego: github.com/cofyc/beego Index | Files | Directories

package beego

import "github.com/cofyc/beego"

Zero-downtime restarts in Go.

Index

Package Files

admin.go app.go beego.go config.go controller.go filter.go flash.go log.go memzipfile.go mime.go reload.go router.go template.go templatefunc.go

Constants

const (
    LevelTrace = iota
    LevelDebug
    LevelInfo
    LevelWarning
    LevelError
    LevelCritical
)

Log levels to control the logging output.

const (
    // default filter execution points
    BeforeRouter = iota
    AfterStatic
    BeforeExec
    AfterExec
    FinishRouter
)
const BEEGO_FLASH_SEP = "#BEEGOFLASH#"

the separation string when encoding flash data.

const (
    // An environment variable when restarting application http listener.
    FDKey = "BEEGO_HOT_FD"
)
const VERSION = "1.1.0"

beego web framework version.

Variables

var (
    BeeApp                 *App // beego application
    AppName                string
    AppPath                string
    AppConfigPath          string
    StaticDir              map[string]string
    TemplateCache          map[string]*template.Template // template caching map
    StaticExtensionsToGzip []string                      // files with should be compressed with gzip (.js,.css,etc)
    HttpAddr               string
    HttpPort               int
    HttpTLS                bool
    HttpCertFile           string
    HttpKeyFile            string
    RecoverPanic           bool // flag of auto recover panic
    AutoRender             bool // flag of render template automatically
    ViewsPath              string
    RunMode                string // run mode, "dev" or "prod"
    AppConfig              config.ConfigContainer
    GlobalSessions         *session.Manager // global session mananger
    SessionOn              bool             // flag of starting session auto. default is false.
    SessionProvider        string           // default session provider, memory, mysql , redis ,etc.
    SessionName            string           // the cookie name when saving session id into cookie.
    SessionGCMaxLifetime   int64            // session gc time for auto cleaning expired session.
    SessionSavePath        string           // if use mysql/redis/file provider, define save path to connection info.
    SessionHashFunc        string           // session hash generation func.
    SessionHashKey         string           // session hash salt string.
    SessionCookieLifeTime  int              // the life time of session id in cookie.
    SessionAutoSetCookie   bool             // auto setcookie
    UseFcgi                bool
    MaxMemory              int64
    EnableGzip             bool // flag of enable gzip
    DirectoryIndex         bool // flag of display directory index. default is false.
    EnableHotUpdate        bool // flag of hot update checking by app self. default is false.
    HttpServerTimeOut      int64
    ErrorsShow             bool   // flag of show errors in page. if true, show error and trace info in page rendered with error template.
    XSRFKEY                string // xsrf hash salt string.
    EnableXSRF             bool   // flag of enable xsrf.
    XSRFExpire             int    // the expiry of xsrf value.
    CopyRequestBody        bool   // flag of copy raw request body in context.
    TemplateLeft           string
    TemplateRight          string
    BeegoServerName        string // beego server name exported in response header.
    EnableAdmin            bool   // flag of enable admin module to log every request info.
    AdminHttpAddr          string // http server configurations for admin module.
    AdminHttpPort          int
)
var (

    // beego template caching map and supported template file extensions.
    BeeTemplates   map[string]*template.Template
    BeeTemplateExt []string
)
var BeeLogger *logs.BeeLogger

logger references the used application logger.

var ErrClosing = errors.New("use of closed network connection")

Export an error equivalent to net.errClosing for use with Accept during a graceful exit.

var ErrInitStart = errors.New("init from")
var FilterMonitorFunc func(string, string, time.Duration) bool

FilterMonitorFunc is default monitor filter when admin module is enable. if this func returns, admin module records qbs for this request by condition of this function logic. usage:

func MyFilterMonitor(method, requestPath string, t time.Duration) bool {
 	if method == "POST" {
		return false
 	}
 	if t.Nanoseconds() < 100 {
		return false
 	}
 	if strings.HasPrefix(requestPath, "/astaxie") {
		return false
 	}
 	return true
}
beego.FilterMonitorFunc = MyFilterMonitor.
var FormType = map[string]bool{
    "text":     true,
    "textarea": true,
    "hidden":   true,
    "password": true,
}

form types for RenderForm function

var (
    // supported http methods.
    HTTPMETHOD = []string{"get", "post", "put", "delete", "patch", "options", "head"}
)
var (
    // custom error when user stop request handler manually.
    USERSTOPRUN = errors.New("User stop run")
)

func AddAPPStartHook Uses

func AddAPPStartHook(hf hookfunc)

The hookfunc will run in beego.Run() such as sessionInit, middlerware start, buildtemplate, admin start

func AddFuncMap Uses

func AddFuncMap(key string, funname interface{}) error

AddFuncMap let user to register a func in the template.

func AddTemplateExt Uses

func AddTemplateExt(ext string)

add new extension for template.

func AdminIndex Uses

func AdminIndex(rw http.ResponseWriter, r *http.Request)

AdminIndex is the default http.Handler for admin module. it matches url pattern "/".

func AssetsCss Uses

func AssetsCss(src string) template.HTML

returns stylesheet link tag with src string.

func AssetsJs Uses

func AssetsJs(src string) template.HTML

returns script tag with src string.

func BuildTemplate Uses

func BuildTemplate(dir string) error

build all template files in a directory. it makes beego can render any template file in view directory.

func CloseSelf Uses

func CloseSelf() error

Kill current running os process.

func CloseZWriter Uses

func CloseZWriter(zwriter io.Writer)

CloseZWriter closes the io.Writer after compressing static file.

func Compare Uses

func Compare(a, b interface{}) (equal bool)

Compare is a quick and dirty comparison function. It will convert whatever you give it to strings and see if the two values are equal. Whitespace is trimmed. Used by the template parser as "eq".

func Critical Uses

func Critical(v ...interface{})

Critical logs a message at critical level.

func Date Uses

func Date(t time.Time, format string) string

Date takes a PHP like date func to Go's time format.

func DateFormat Uses

func DateFormat(t time.Time, layout string) (datestring string)

DateFormat takes a time and a layout string and returns a string with the formatted date. Used by the template parser as "dateformat"

func DateParse Uses

func DateParse(dateString, format string) (time.Time, error)

Parse Date use PHP time format.

func Debug Uses

func Debug(v ...interface{})

Debug logs a message at debug level.

func Error Uses

func Error(v ...interface{})

Error logs a message at error level.

func GetAcceptEncodingZip Uses

func GetAcceptEncodingZip(r *http.Request) string

GetAcceptEncodingZip returns accept encoding format in http header. zip is first, then deflate if both accepted. If no accepted, return empty string.

func GetInitListener Uses

func GetInitListener(tcpaddr *net.TCPAddr) (l net.Listener, err error)

Get current net.Listen in running process.

func HasTemplateExt Uses

func HasTemplateExt(paths string) bool

return this path contains supported template extension of beego or not.

func Healthcheck Uses

func Healthcheck(rw http.ResponseWriter, req *http.Request)

Healthcheck is a http.Handler calling health checking and showing the result. it's in "/healthcheck" pattern in admin module.

func Html2str Uses

func Html2str(html string) string

Html2str returns escaping text convert from html.

func Htmlquote Uses

func Htmlquote(src string) string

Htmlquote returns quoted html string.

func Htmlunquote Uses

func Htmlunquote(src string) string

Htmlunquote returns unquoted html string.

func Info Uses

func Info(v ...interface{})

Info logs a message at info level.

func ListConf Uses

func ListConf(rw http.ResponseWriter, r *http.Request)

ListConf is the http.Handler of displaying all beego configuration values as key/value pair. it's registered with url pattern "/listconf" in admin module.

func ParseConfig Uses

func ParseConfig() (err error)

ParseConfig parsed default config file. now only support ini, next will support json.

func ParseForm Uses

func ParseForm(form url.Values, obj interface{}) error

parse form values to struct via tag.

func ProfIndex Uses

func ProfIndex(rw http.ResponseWriter, r *http.Request)

ProfIndex is a http.Handler for showing profile command. it's in url pattern "/prof" in admin module.

func QpsIndex Uses

func QpsIndex(rw http.ResponseWriter, r *http.Request)

QpsIndex is the http.Handler for writing qbs statistics map result info in http.ResponseWriter. it's registered with url pattern "/qbs" in admin module.

func RenderForm Uses

func RenderForm(obj interface{}) template.HTML

render object to form html. obj must be a struct pointer.

func Restart Uses

func Restart(l net.Listener) error

Re-exec this image without dropping the listener passed to this function.

func Run Uses

func Run()

Run beego application. it's alias of App.Run.

func RunTask Uses

func RunTask(rw http.ResponseWriter, req *http.Request)

RunTask is a http.Handler to run a Task from the "query string. the request url likes /runtask?taskname=sendmail.

func SetLevel Uses

func SetLevel(l int)

SetLogLevel sets the global log level used by the simple logger.

func SetLogger Uses

func SetLogger(adaptername string, config string)

SetLogger sets a new logger.

func Str2html Uses

func Str2html(raw string) template.HTML

Convert string to template.HTML type.

func Substr Uses

func Substr(s string, start, length int) string

Substr returns the substr from start to length.

func TaskStatus Uses

func TaskStatus(rw http.ResponseWriter, req *http.Request)

TaskStatus is a http.Handler with running task status (task name, status and the last execution). it's in "/task" pattern in admin module.

func Trace Uses

func Trace(v ...interface{})

Trace logs a message at trace level.

func UrlFor Uses

func UrlFor(endpoint string, values ...string) string

UrlFor returns url string with another registered controller handler with params.

usage:
UrlFor(".index")
print UrlFor("index")
print UrlFor("login")
print UrlFor("login", "next","/"")
print UrlFor("profile", "username","John Doe")
result:
/
/login
/login?next=/
/user/John%20Doe

func WaitSignal Uses

func WaitSignal(l net.Listener) error

Listener waits signal to kill or interrupt then restart.

func Warn Uses

func Warn(v ...interface{})

Warning logs a message at warning level.

type AdminApp Uses

type AdminApp struct {
    // contains filtered or unexported fields
}

AdminApp is an http.HandlerFunc map used as BeeAdminApp.

var BeeAdminApp *AdminApp

BeeAdminApp is the default AdminApp used by admin module.

func (*AdminApp) Route Uses

func (admin *AdminApp) Route(pattern string, f http.HandlerFunc)

Route adds http.HandlerFunc to AdminApp with url pattern.

func (*AdminApp) Run Uses

func (admin *AdminApp) Run()

Run AdminApp http server. Its addr is defined in configuration file as adminhttpaddr and adminhttpport.

type App Uses

type App struct {
    Handlers *ControllerRegistor
}

App defines beego application with a new PatternServeMux.

func AddFilter Uses

func AddFilter(pattern, action string, filter FilterFunc) *App

[Deprecated] use InsertFilter. Filter adds a FilterFunc under pattern condition and named action. The actions contains BeforeRouter,AfterStatic,BeforeExec,AfterExec and FinishRouter. it's alias of App.Filter.

func AddGroupRouter Uses

func AddGroupRouter(prefix string, groups GroupRouters) *App

AddGroupRouter with the prefix it will register the router in BeeApp the follow code is write in modules: GR:=NewGroupRouters() GR.AddRouter("/login",&UserController,"get:Login") GR.AddRouter("/logout",&UserController,"get:Logout") GR.AddRouter("/register",&UserController,"get:Reg") the follow code is write in app: import "github.com/beego/modules/auth" AddRouterGroup("/admin", auth.GR)

func AutoPrefix Uses

func AutoPrefix(prefix string, c ControllerInterface) *App

AutoPrefix adds controller handler to BeeApp with prefix. it's same to App.AutoRouterWithPrefix.

func AutoRouter Uses

func AutoRouter(c ControllerInterface) *App

AutoRouter adds defined controller handler to BeeApp. it's same to App.AutoRouter.

func DelStaticPath Uses

func DelStaticPath(url string) *App

DelStaticPath removes the static folder setting in this url pattern in beego application. it's alias of App.DelStaticPath.

func Errorhandler Uses

func Errorhandler(err string, h http.HandlerFunc) *App

ErrorHandler registers http.HandlerFunc to each http err code string. usage:

beego.ErrorHandler("404",NotFound)
beego.ErrorHandler("500",InternalServerError)

func InsertFilter Uses

func InsertFilter(pattern string, pos int, filter FilterFunc) *App

InsertFilter adds a FilterFunc with pattern condition and action constant. The pos means action constant including beego.BeforeRouter, beego.AfterStatic, beego.BeforeExec, beego.AfterExec and beego.FinishRouter. it's alias of App.InsertFilter.

func NewApp Uses

func NewApp() *App

NewApp returns a new beego application.

func RESTRouter Uses

func RESTRouter(rootpath string, c ControllerInterface) *App

RESTRouter adds a restful controller handler to BeeApp. its' controller implements beego.ControllerInterface and defines a param "pattern/:objectId" to visit each resource.

func Router Uses

func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *App

Router adds a patterned controller handler to BeeApp. it's an alias method of App.Router.

func SetStaticPath Uses

func SetStaticPath(url string, path string) *App

SetStaticPath sets static directory and url prefix to BeeApp. it's alias of App.SetStaticPath.

func SetViewsPath Uses

func SetViewsPath(path string) *App

SetViewsPath sets view directory to BeeApp. it's alias of App.SetViewsPath.

func (*App) AutoRouter Uses

func (app *App) AutoRouter(c ControllerInterface) *App

AutoRouter adds beego-defined controller handler. if beego.AddAuto(&MainContorlller{}) and MainController has methods List and Page, visit the url /main/list to exec List function or /main/page to exec Page function.

func (*App) AutoRouterWithPrefix Uses

func (app *App) AutoRouterWithPrefix(prefix string, c ControllerInterface) *App

AutoRouterWithPrefix adds beego-defined controller handler with prefix. if beego.AutoPrefix("/admin",&MainContorlller{}) and MainController has methods List and Page, visit the url /admin/main/list to exec List function or /admin/main/page to exec Page function.

func (*App) DelStaticPath Uses

func (app *App) DelStaticPath(url string) *App

DelStaticPath removes the static folder setting in this url pattern in beego application. it returns beego application self.

func (*App) Filter Uses

func (app *App) Filter(pattern, action string, filter FilterFunc) *App

[Deprecated] use InsertFilter. Filter adds a FilterFunc under pattern condition and named action. The actions contains BeforeRouter,AfterStatic,BeforeExec,AfterExec and FinishRouter.

func (*App) InsertFilter Uses

func (app *App) InsertFilter(pattern string, pos int, filter FilterFunc) *App

InsertFilter adds a FilterFunc with pattern condition and action constant. The pos means action constant including beego.BeforeRouter, beego.AfterStatic, beego.BeforeExec, beego.AfterExec and beego.FinishRouter.

func (*App) Router Uses

func (app *App) Router(path string, c ControllerInterface, mappingMethods ...string) *App

Router adds a url-patterned controller handler. The path argument supports regex rules and specific placeholders. The c argument needs a controller handler implemented beego.ControllerInterface. The mapping methods argument only need one string to define custom router rules. usage:

simple router
beego.Router("/admin", &admin.UserController{})
beego.Router("/admin/index", &admin.ArticleController{})

regex router

beego.Router(“/api/:id([0-9]+)“, &controllers.RController{})

custom rules
beego.Router("/api/list",&RestController{},"*:ListFood")
beego.Router("/api/create",&RestController{},"post:CreateFood")
beego.Router("/api/update",&RestController{},"put:UpdateFood")
beego.Router("/api/delete",&RestController{},"delete:DeleteFood")

func (*App) Run Uses

func (app *App) Run()

Run beego application.

func (*App) SetStaticPath Uses

func (app *App) SetStaticPath(url string, path string) *App

SetStaticPath sets static directory path and proper url pattern in beego application. if beego.SetStaticPath("static","public"), visit /static/* to load static file in folder "public". it returns beego application self.

func (*App) SetViewsPath Uses

func (app *App) SetViewsPath(path string) *App

SetViewsPath sets view directory path in beego application. it returns beego application self.

func (*App) UrlFor Uses

func (app *App) UrlFor(endpoint string, values ...string) string

UrlFor creates a url with another registered controller handler with params. The endpoint is formed as path.controller.name to defined the controller method which will run. The values need key-pair data to assign into controller method.

type Controller Uses

type Controller struct {
    Ctx  *context.Context
    Data map[interface{}]interface{}

    TplNames       string
    Layout         string
    LayoutSections map[string]string // the key is the section name and the value is the template name
    TplExt         string

    CruSession    session.SessionStore
    XSRFExpire    int
    AppController interface{}
    EnableReander bool
    // contains filtered or unexported fields
}

Controller defines some basic http request handler operations, such as http context, template and view, session and xsrf.

func (*Controller) Abort Uses

func (c *Controller) Abort(code string)

Aborts stops controller handler and show the error data if code is defined in ErrorMap or code string.

func (*Controller) CheckXsrfCookie Uses

func (c *Controller) CheckXsrfCookie() bool

CheckXsrfCookie checks xsrf token in this request is valid or not. the token can provided in request header "X-Xsrftoken" and "X-CsrfToken" or in form field value named as "_xsrf".

func (*Controller) DelSession Uses

func (c *Controller) DelSession(name interface{})

SetSession removes value from session.

func (*Controller) Delete Uses

func (c *Controller) Delete()

Delete adds a request function to handle DELETE request.

func (*Controller) DestroySession Uses

func (c *Controller) DestroySession()

DestroySession cleans session data and session cookie.

func (*Controller) Finish Uses

func (c *Controller) Finish()

Finish runs after request function execution.

func (*Controller) Get Uses

func (c *Controller) Get()

Get adds a request function to handle GET request.

func (*Controller) GetBool Uses

func (c *Controller) GetBool(key string) (bool, error)

GetBool returns input value as bool.

func (*Controller) GetControllerAndAction Uses

func (c *Controller) GetControllerAndAction() (controllerName, actionName string)

GetControllerAndAction gets the executing controller name and action name.

func (*Controller) GetFile Uses

func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, error)

GetFile returns the file data in file upload field named as key. it returns the first one of multi-uploaded files.

func (*Controller) GetFloat Uses

func (c *Controller) GetFloat(key string) (float64, error)

GetFloat returns input value as float64.

func (*Controller) GetInt Uses

func (c *Controller) GetInt(key string) (int64, error)

GetInt returns input value as int64.

func (*Controller) GetSecureCookie Uses

func (c *Controller) GetSecureCookie(Secret, key string) (string, bool)

GetSecureCookie returns decoded cookie value from encoded browser cookie values.

func (*Controller) GetSession Uses

func (c *Controller) GetSession(name interface{}) interface{}

GetSession gets value from session.

func (*Controller) GetString Uses

func (c *Controller) GetString(key string) string

GetString returns the input value by key string.

func (*Controller) GetStrings Uses

func (c *Controller) GetStrings(key string) []string

GetStrings returns the input string slice by key string. it's designed for multi-value input field such as checkbox(input[type=checkbox]), multi-selection.

func (*Controller) Head Uses

func (c *Controller) Head()

Head adds a request function to handle HEAD request.

func (*Controller) Init Uses

func (c *Controller) Init(ctx *context.Context, controllerName, actionName string, app interface{})

Init generates default values of controller operations.

func (*Controller) Input Uses

func (c *Controller) Input() url.Values

Input returns the input data map from POST or PUT request body and query string.

func (*Controller) IsAjax Uses

func (c *Controller) IsAjax() bool

IsAjax returns this request is ajax or not.

func (*Controller) Options Uses

func (c *Controller) Options()

Options adds a request function to handle OPTIONS request.

func (*Controller) ParseForm Uses

func (c *Controller) ParseForm(obj interface{}) error

ParseForm maps input data map to obj struct.

func (*Controller) Patch Uses

func (c *Controller) Patch()

Patch adds a request function to handle PATCH request.

func (*Controller) Post Uses

func (c *Controller) Post()

Post adds a request function to handle POST request.

func (*Controller) Prepare Uses

func (c *Controller) Prepare()

Prepare runs after Init before request function execution.

func (*Controller) Put Uses

func (c *Controller) Put()

Put adds a request function to handle PUT request.

func (*Controller) Redirect Uses

func (c *Controller) Redirect(url string, code int)

Redirect sends the redirection response to url with status code.

func (*Controller) Render Uses

func (c *Controller) Render() error

Render sends the response with rendered template bytes as text/html type.

func (*Controller) RenderBytes Uses

func (c *Controller) RenderBytes() ([]byte, error)

RenderBytes returns the bytes of rendered template string. Do not send out response.

func (*Controller) RenderString Uses

func (c *Controller) RenderString() (string, error)

RenderString returns the rendered template string. Do not send out response.

func (*Controller) SaveToFile Uses

func (c *Controller) SaveToFile(fromfile, tofile string) error

SaveToFile saves uploaded file to new path. it only operates the first one of mutil-upload form file field.

func (*Controller) ServeJson Uses

func (c *Controller) ServeJson(encoding ...bool)

ServeJson sends a json response with encoding charset.

func (*Controller) ServeJsonp Uses

func (c *Controller) ServeJsonp()

ServeJsonp sends a jsonp response.

func (*Controller) ServeXml Uses

func (c *Controller) ServeXml()

ServeXml sends xml response.

func (*Controller) SessionRegenerateID Uses

func (c *Controller) SessionRegenerateID()

SessionRegenerateID regenerates session id for this session. the session data have no changes.

func (*Controller) SetSecureCookie Uses

func (c *Controller) SetSecureCookie(Secret, name, val string, age int64)

SetSecureCookie puts value into cookie after encoded the value.

func (*Controller) SetSession Uses

func (c *Controller) SetSession(name interface{}, value interface{})

SetSession puts value into session.

func (*Controller) StartSession Uses

func (c *Controller) StartSession() session.SessionStore

StartSession starts session and load old session data info this controller.

func (*Controller) StopRun Uses

func (c *Controller) StopRun()

StopRun makes panic of USERSTOPRUN error and go to recover function if defined.

func (*Controller) UrlFor Uses

func (c *Controller) UrlFor(endpoint string, values ...string) string

UrlFor does another controller handler in this request function. it goes to this controller method if endpoint is not clear.

func (*Controller) XsrfFormHtml Uses

func (c *Controller) XsrfFormHtml() string

XsrfFormHtml writes an input field contains xsrf token value.

func (*Controller) XsrfToken Uses

func (c *Controller) XsrfToken() string

XsrfToken creates a xsrf token string and returns.

type ControllerInterface Uses

type ControllerInterface interface {
    Init(ct *context.Context, controllerName, actionName string, app interface{})
    Prepare()
    Get()
    Post()
    Delete()
    Put()
    Head()
    Patch()
    Options()
    Finish()
    Render() error
    XsrfToken() string
    CheckXsrfCookie() bool
}

ControllerInterface is an interface to uniform all controller handler.

type ControllerRegistor Uses

type ControllerRegistor struct {
    // contains filtered or unexported fields
}

ControllerRegistor containers registered router rules, controller handlers and filters.

func NewControllerRegistor Uses

func NewControllerRegistor() *ControllerRegistor

NewControllerRegistor returns a new ControllerRegistor.

func (*ControllerRegistor) Add Uses

func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingMethods ...string)

Add controller handler and pattern rules to ControllerRegistor. usage:

default methods is the same name as method
Add("/user",&UserController{})
Add("/api/list",&RestController{},"*:ListFood")
Add("/api/create",&RestController{},"post:CreateFood")
Add("/api/update",&RestController{},"put:UpdateFood")
Add("/api/delete",&RestController{},"delete:DeleteFood")
Add("/api",&RestController{},"get,post:ApiFunc")
Add("/simple",&SimpleController{},"get:GetFunc;post:PostFunc")

func (*ControllerRegistor) AddAuto Uses

func (p *ControllerRegistor) AddAuto(c ControllerInterface)

Add auto router to ControllerRegistor. example beego.AddAuto(&MainContorlller{}), MainController has method List and Page. visit the url /main/list to execute List function /main/page to execute Page function.

func (*ControllerRegistor) AddAutoPrefix Uses

func (p *ControllerRegistor) AddAutoPrefix(prefix string, c ControllerInterface)

Add auto router to ControllerRegistor with prefix. example beego.AddAutoPrefix("/admin",&MainContorlller{}), MainController has method List and Page. visit the url /admin/main/list to execute List function /admin/main/page to execute Page function.

func (*ControllerRegistor) AddFilter Uses

func (p *ControllerRegistor) AddFilter(pattern, action string, filter FilterFunc) error

[Deprecated] use InsertFilter. Add FilterFunc with pattern for action.

func (*ControllerRegistor) InsertFilter Uses

func (p *ControllerRegistor) InsertFilter(pattern string, pos int, filter FilterFunc) error

Add a FilterFunc with pattern rule and action constant.

func (*ControllerRegistor) ServeHTTP Uses

func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)

Implement http.Handler interface.

func (*ControllerRegistor) UrlFor Uses

func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string

UrlFor does another controller handler in this request function. it can access any controller method.

type FilterFunc Uses

type FilterFunc func(*context.Context)

FilterFunc defines filter function type.

type FilterRouter Uses

type FilterRouter struct {
    // contains filtered or unexported fields
}

FilterRouter defines filter operation before controller handler execution. it can match patterned url and do filter function when action arrives.

func (*FilterRouter) ValidRouter Uses

func (mr *FilterRouter) ValidRouter(router string) (bool, map[string]string)

ValidRouter check current request is valid for this filter. if matched, returns parsed params in this request by defined filter router pattern.

type FlashData Uses

type FlashData struct {
    Data map[string]string
}

FlashData is a tools to maintain data when using across request.

func NewFlash Uses

func NewFlash() *FlashData

NewFlash return a new empty FlashData struct.

func ReadFromRequest Uses

func ReadFromRequest(c *Controller) *FlashData

ReadFromRequest parsed flash data from encoded values in cookie.

func (*FlashData) Error Uses

func (fd *FlashData) Error(msg string, args ...interface{})

Error writes error message to flash.

func (*FlashData) Notice Uses

func (fd *FlashData) Notice(msg string, args ...interface{})

Notice writes notice message to flash.

func (*FlashData) Store Uses

func (fd *FlashData) Store(c *Controller)

Store does the saving operation of flash data. the data are encoded and saved in cookie.

func (*FlashData) Warning Uses

func (fd *FlashData) Warning(msg string, args ...interface{})

Warning writes warning message to flash.

type GroupRouters Uses

type GroupRouters []groupRouter

RouterGroups which will store routers

func NewGroupRouters Uses

func NewGroupRouters() GroupRouters

Get a new GroupRouters

func (GroupRouters) AddAuto Uses

func (gr GroupRouters) AddAuto(c ControllerInterface)

func (GroupRouters) AddRouter Uses

func (gr GroupRouters) AddRouter(pattern string, c ControllerInterface, mappingMethod ...string)

Add Router in the GroupRouters it is for plugin or module to register router

type MemFile Uses

type MemFile struct {
    // contains filtered or unexported fields
}

MemFile contains MemFileInfo and bytes offset when reading. it implements io.Reader,io.ReadCloser and io.Seeker.

func OpenMemZipFile Uses

func OpenMemZipFile(path string, zip string) (*MemFile, error)

OpenMemZipFile returns MemFile object with a compressed static file. it's used for serve static file if gzip enable.

func (*MemFile) Close Uses

func (f *MemFile) Close() error

Close memfile.

func (*MemFile) Read Uses

func (f *MemFile) Read(p []byte) (n int, err error)

Read bytes from the compressed file bytes.

func (*MemFile) Readdir Uses

func (f *MemFile) Readdir(count int) ([]os.FileInfo, error)

read os.FileInfo of files in directory of memfile. it returns empty slice.

func (*MemFile) Seek Uses

func (f *MemFile) Seek(offset int64, whence int) (ret int64, err error)

Read bytes from the compressed file bytes by seeker.

func (*MemFile) Stat Uses

func (f *MemFile) Stat() (os.FileInfo, error)

Get os.FileInfo of memfile.

type MemFileInfo Uses

type MemFileInfo struct {
    os.FileInfo
    // contains filtered or unexported fields
}

MemFileInfo contains a compressed file bytes and file information. it implements os.FileInfo interface.

func (*MemFileInfo) IsDir Uses

func (fi *MemFileInfo) IsDir() bool

IsDir returns the compressing file is a directory or not.

func (*MemFileInfo) ModTime Uses

func (fi *MemFileInfo) ModTime() time.Time

ModTime returns the last modified time of raw file.

func (*MemFileInfo) Mode Uses

func (fi *MemFileInfo) Mode() os.FileMode

Mode returns file mode.

func (*MemFileInfo) Name Uses

func (fi *MemFileInfo) Name() string

Name returns the compressed filename.

func (*MemFileInfo) Size Uses

func (fi *MemFileInfo) Size() int64

Size returns the raw file content size, not compressed size.

func (*MemFileInfo) Sys Uses

func (fi *MemFileInfo) Sys() interface{}

return nil. implement the os.FileInfo interface method.

Directories

PathSynopsis
cache
config
context
example/beeapi
example/beeapi/controllers
example/beeapi/models
example/chat
example/chat/controllers
httplib
logs
middleware
orm
plugins/authbasic auth for plugin
session
testing
toolboxmost reference from github.com/realint/dbgutil
utils
utils/captchaan example for use captcha
validation

Package beego imports 38 packages (graph). Updated 2016-11-11. Refresh now. Tools for package owners.