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

package beego

import "github.com/krasnoukhov/beego"

Zero-downtime restarts in Go.

Index

Package Files

app.go beego.go config.go controller.go filter.go flash.go log.go reload.go router.go safemap.go template.go utils.go

Constants

const (
    LevelTrace = iota
    LevelDebug
    LevelInfo
    LevelWarning
    LevelError
    LevelCritical
)

Log levels to control the logging output.

const (
    FDKey = "BEEGO_HOT_FD"
)
const VERSION = "0.9.0"

Variables

var (
    BeeApp        *App
    AppName       string
    AppPath       string
    AppConfigPath string
    StaticDir     map[string]string
    TemplateCache map[string]*template.Template
    HttpAddr      string
    HttpPort      int
    HttpTLS       bool
    HttpCertFile  string
    HttpKeyFile   string
    RecoverPanic  bool
    AutoRender    bool
    PprofOn       bool
    ViewsPath     string
    RunMode       string //"dev" or "prod"
    AppConfig     config.ConfigContainer
    //related to session
    GlobalSessions       *session.Manager //GlobalSessions
    SessionOn            bool             // whether auto start session,default is false
    SessionProvider      string           // default session provider  memory mysql redis
    SessionName          string           // sessionName cookie's name
    SessionGCMaxLifetime int64            // session's gc maxlifetime
    SessionSavePath      string           // session savepath if use mysql/redis/file this set to the connectinfo
    UseFcgi              bool
    MaxMemory            int64
    EnableGzip           bool   // enable gzip
    DirectoryIndex       bool   //enable DirectoryIndex default is false
    EnableHotUpdate      bool   //enable HotUpdate default is false
    HttpServerTimeOut    int64  //set httpserver timeout
    ErrorsShow           bool   //set weather show errors
    XSRFKEY              string //set XSRF
    EnableXSRF           bool
    XSRFExpire           int
    CopyRequestBody      bool //When in raw application, You want to the reqeustbody
    TemplateLeft         string
    TemplateRight        string
)
var (
    BeeTemplates   map[string]*template.Template
    BeeTemplateExt []string
)
var BeeLogger *logs.BeeLogger

logger references the used application logger.

var DatePatterns = []string{

    "Y", "2006",
    "y", "06",

    "m", "01",
    "n", "1",
    "M", "Jan",
    "F", "January",

    "d", "02",
    "j", "2",

    "D", "Mon",
    "l", "Monday",

    "g", "3",
    "G", "15",
    "h", "03",
    "H", "15",

    "a", "pm",
    "A", "PM",

    "i", "04",
    "s", "05",

    "T", "MST",
    "P", "-07:00",
    "O", "-0700",

    "r", time.RFC1123Z,
}
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 FormType = map[string]bool{
    "text":     true,
    "textarea": true,
    "hidden":   true,
    "password": true,
}

form types for RenderForm function

var HTTPMETHOD = []string{"get", "post", "put", "delete", "patch", "options", "head"}

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)

func BuildTemplate Uses

func BuildTemplate(dir string) error

func CloseSelf Uses

func CloseSelf() error

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 GetInitListner Uses

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

func HasTemplateEXt Uses

func HasTemplateEXt(paths string) bool

func Html2str Uses

func Html2str(html string) string

Html2str() returns escaping text convert from html

func Htmlquote Uses

func Htmlquote(src string) string

func Htmlunquote Uses

func Htmlunquote(src string) string

func Info Uses

func Info(v ...interface{})

Info logs a message at info level.

func ParseConfig Uses

func ParseConfig() (err error)

func ParseForm Uses

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

parse form values to struct via tag

func RenderForm Uses

func RenderForm(obj interface{}) template.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()

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

func Substr Uses

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

func Trace Uses

func Trace(v ...interface{})

Trace logs a message at trace level.

func WaitSignal Uses

func WaitSignal(l net.Listener) error

func Warn Uses

func Warn(v ...interface{})

Warning logs a message at warning level.

type App Uses

type App struct {
    Handlers *ControllerRegistor
}

func AddFilter Uses

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

action has four values: BeforRouter AfterStatic BeforExec AfterExec

func AutoRouter Uses

func AutoRouter(c ControllerInterface) *App

func DelStaticPath Uses

func DelStaticPath(url string) *App

func Errorhandler Uses

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

func NewApp Uses

func NewApp() *App

New returns a new PatternServeMux.

func RESTRouter Uses

func RESTRouter(rootpath string, c ControllerInterface) *App

func Router Uses

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

func SetStaticPath Uses

func SetStaticPath(url string, path string) *App

func SetViewsPath Uses

func SetViewsPath(path string) *App

func (*App) AutoRouter Uses

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

func (*App) DelStaticPath Uses

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

func (*App) Filter Uses

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

func (*App) Router Uses

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

func (*App) Run Uses

func (app *App) Run()

func (*App) SetStaticPath Uses

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

func (*App) SetViewsPath Uses

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

type BeeMap Uses

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

func NewBeeMap Uses

func NewBeeMap() *BeeMap

func (*BeeMap) Check Uses

func (m *BeeMap) Check(k interface{}) bool

Returns true if k is exist in the map.

func (*BeeMap) Delete Uses

func (m *BeeMap) Delete(k interface{})

func (*BeeMap) Get Uses

func (m *BeeMap) Get(k interface{}) interface{}

Get from maps return the k's value

func (*BeeMap) Items Uses

func (m *BeeMap) Items() map[interface{}]interface{}

func (*BeeMap) Set Uses

func (m *BeeMap) Set(k interface{}, v interface{}) bool

Maps the given key and value. Returns false if the key is already in the map and changes nothing.

type Controller Uses

type Controller struct {
    Ctx       *context.Context
    Data      map[interface{}]interface{}
    ChildName string
    TplNames  string
    Layout    string
    TplExt    string

    CruSession session.SessionStore
    XSRFExpire int
    // contains filtered or unexported fields
}

func (*Controller) Abort Uses

func (c *Controller) Abort(code string)

func (*Controller) CheckXsrfCookie Uses

func (c *Controller) CheckXsrfCookie() bool

func (*Controller) DelSession Uses

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

func (*Controller) Delete Uses

func (c *Controller) Delete()

func (*Controller) DestroySession Uses

func (c *Controller) DestroySession()

func (*Controller) Destructor Uses

func (c *Controller) Destructor()

func (*Controller) Finish Uses

func (c *Controller) Finish()

func (*Controller) Get Uses

func (c *Controller) Get()

func (*Controller) GetBool Uses

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

func (*Controller) GetFile Uses

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

func (*Controller) GetFloat Uses

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

func (*Controller) GetInt Uses

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

func (*Controller) GetSession Uses

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

func (*Controller) GetString Uses

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

func (*Controller) GetStrings Uses

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

func (*Controller) GoToFunc Uses

func (c *Controller) GoToFunc(funcname string)

func (*Controller) Head Uses

func (c *Controller) Head()

func (*Controller) Init Uses

func (c *Controller) Init(ctx *context.Context, childName string)

func (*Controller) Input Uses

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

func (*Controller) IsAjax Uses

func (c *Controller) IsAjax() bool

func (*Controller) Options Uses

func (c *Controller) Options()

func (*Controller) ParseForm Uses

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

func (*Controller) Patch Uses

func (c *Controller) Patch()

func (*Controller) Post Uses

func (c *Controller) Post()

func (*Controller) Prepare Uses

func (c *Controller) Prepare()

func (*Controller) Put Uses

func (c *Controller) Put()

func (*Controller) Redirect Uses

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

func (*Controller) Render Uses

func (c *Controller) Render() error

func (*Controller) RenderBytes Uses

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

func (*Controller) RenderString Uses

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

func (*Controller) SaveToFile Uses

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

func (*Controller) ServeJson Uses

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

func (*Controller) ServeJsonp Uses

func (c *Controller) ServeJsonp()

func (*Controller) ServeXml Uses

func (c *Controller) ServeXml()

func (*Controller) SetSession Uses

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

func (*Controller) StartSession Uses

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

func (*Controller) XsrfFormHtml Uses

func (c *Controller) XsrfFormHtml() string

func (*Controller) XsrfToken Uses

func (c *Controller) XsrfToken() string

type ControllerInterface Uses

type ControllerInterface interface {
    Init(ct *context.Context, childName string)
    Prepare()
    Get()
    Post()
    Delete()
    Put()
    Head()
    Patch()
    Options()
    Finish()
    Render() error
}

type ControllerRegistor Uses

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

func NewControllerRegistor Uses

func NewControllerRegistor() *ControllerRegistor

func (*ControllerRegistor) Add Uses

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

methods support like this: 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)

func (*ControllerRegistor) AddFilter Uses

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

Filter adds the middleware filter.

func (*ControllerRegistor) ServeHTTP Uses

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

AutoRoute

type FilterFunc Uses

type FilterFunc func(*context.Context)

type FilterRouter Uses

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

func (*FilterRouter) ValidRouter Uses

func (mr *FilterRouter) ValidRouter(router string) bool

type FlashData Uses

type FlashData struct {
    Data map[string]string
}

func NewFlash Uses

func NewFlash() *FlashData

func ReadFromRequest Uses

func ReadFromRequest(c *Controller) *FlashData

func (*FlashData) Error Uses

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

func (*FlashData) Notice Uses

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

func (*FlashData) Store Uses

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

func (*FlashData) Warning Uses

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

Directories

PathSynopsis
cache
config
context
httplib
logs
middleware
orm
session
testing
validation

Package beego imports 33 packages (graph) and is imported by 4 packages. Updated 2016-07-26. Refresh now. Tools for package owners.