diff --git a/admin.go b/admin.go index db52647e..d9c96dfd 100644 --- a/admin.go +++ b/admin.go @@ -52,6 +52,7 @@ var beeAdminApp *adminApp // return true // } // beego.FilterMonitorFunc = MyFilterMonitor. +// Deprecated: using pkg/, we will delete this in v2.1.0 var FilterMonitorFunc func(string, string, time.Duration, string, int) bool func init() { @@ -201,6 +202,7 @@ func list(root string, p interface{}, m M) { } // PrintTree prints all registered routers. +// Deprecated: using pkg/, we will delete this in v2.1.0 func PrintTree() M { var ( content = M{} @@ -432,6 +434,7 @@ func (admin *adminApp) Route(pattern string, f http.HandlerFunc) { // Run adminApp http server. // Its addr is defined in configuration file as adminhttpaddr and adminhttpport. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (admin *adminApp) Run() { if len(toolbox.AdminTaskList) > 0 { toolbox.StartTask() diff --git a/app.go b/app.go index 3dee8999..d86188c0 100644 --- a/app.go +++ b/app.go @@ -35,6 +35,7 @@ import ( var ( // BeeApp is an application instance + // Deprecated: using pkg/, we will delete this in v2.1.0 BeeApp *App ) @@ -50,6 +51,7 @@ type App struct { } // NewApp returns a new beego application. +// Deprecated: using pkg/, we will delete this in v2.1.0 func NewApp() *App { cr := NewControllerRegister() app := &App{Handlers: cr, Server: &http.Server{}} @@ -57,9 +59,11 @@ func NewApp() *App { } // MiddleWare function for http.Handler +// Deprecated: using pkg/, we will delete this in v2.1.0 type MiddleWare func(http.Handler) http.Handler // Run beego application. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (app *App) Run(mws ...MiddleWare) { addr := BConfig.Listen.HTTPAddr @@ -254,6 +258,7 @@ func (app *App) Run(mws ...MiddleWare) { // beego.Router("/api/create",&RestController{},"post:CreateFood") // beego.Router("/api/update",&RestController{},"put:UpdateFood") // beego.Router("/api/delete",&RestController{},"delete:DeleteFood") +// Deprecated: using pkg/, we will delete this in v2.1.0 func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *App { BeeApp.Handlers.Add(rootpath, c, mappingMethods...) return BeeApp @@ -268,6 +273,7 @@ func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *A // Usage (replace "GET" with "*" for all methods): // beego.UnregisterFixedRoute("/yourpreviouspath", "GET") // beego.Router("/yourpreviouspath", yourControllerAddress, "get:GetNewPage") +// Deprecated: using pkg/, we will delete this in v2.1.0 func UnregisterFixedRoute(fixedRoute string, method string) *App { subPaths := splitPath(fixedRoute) if method == "" || method == "*" { @@ -364,6 +370,7 @@ func findAndRemoveSingleTree(entryPointTree *Tree) { // the comments @router url methodlist // url support all the function Router's pattern // methodlist [get post head put delete options *] +// Deprecated: using pkg/, we will delete this in v2.1.0 func Include(cList ...ControllerInterface) *App { BeeApp.Handlers.Include(cList...) return BeeApp @@ -372,6 +379,7 @@ func Include(cList ...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. +// Deprecated: using pkg/, we will delete this in v2.1.0 func RESTRouter(rootpath string, c ControllerInterface) *App { Router(rootpath, c) Router(path.Join(rootpath, ":objectId"), c) @@ -382,6 +390,7 @@ func RESTRouter(rootpath string, c ControllerInterface) *App { // it's same to App.AutoRouter. // 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. +// Deprecated: using pkg/, we will delete this in v2.1.0 func AutoRouter(c ControllerInterface) *App { BeeApp.Handlers.AddAuto(c) return BeeApp @@ -391,6 +400,7 @@ func AutoRouter(c ControllerInterface) *App { // it's same to App.AutoRouterWithPrefix. // 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. +// Deprecated: using pkg/, we will delete this in v2.1.0 func AutoPrefix(prefix string, c ControllerInterface) *App { BeeApp.Handlers.AddAutoPrefix(prefix, c) return BeeApp @@ -401,6 +411,7 @@ func AutoPrefix(prefix string, c ControllerInterface) *App { // beego.Get("/", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Get(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Get(rootpath, f) return BeeApp @@ -411,6 +422,7 @@ func Get(rootpath string, f FilterFunc) *App { // beego.Post("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Post(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Post(rootpath, f) return BeeApp @@ -421,6 +433,7 @@ func Post(rootpath string, f FilterFunc) *App { // beego.Delete("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Delete(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Delete(rootpath, f) return BeeApp @@ -431,6 +444,7 @@ func Delete(rootpath string, f FilterFunc) *App { // beego.Put("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Put(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Put(rootpath, f) return BeeApp @@ -441,6 +455,7 @@ func Put(rootpath string, f FilterFunc) *App { // beego.Head("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Head(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Head(rootpath, f) return BeeApp @@ -451,6 +466,7 @@ func Head(rootpath string, f FilterFunc) *App { // beego.Options("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Options(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Options(rootpath, f) return BeeApp @@ -461,6 +477,7 @@ func Options(rootpath string, f FilterFunc) *App { // beego.Patch("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Patch(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Patch(rootpath, f) return BeeApp @@ -471,6 +488,7 @@ func Patch(rootpath string, f FilterFunc) *App { // beego.Any("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Any(rootpath string, f FilterFunc) *App { BeeApp.Handlers.Any(rootpath, f) return BeeApp @@ -481,6 +499,7 @@ func Any(rootpath string, f FilterFunc) *App { // beego.Handler("/api", http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) { // fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) // })) +// Deprecated: using pkg/, we will delete this in v2.1.0 func Handler(rootpath string, h http.Handler, options ...interface{}) *App { BeeApp.Handlers.Handler(rootpath, h, options...) return BeeApp @@ -490,6 +509,7 @@ func Handler(rootpath string, h http.Handler, options ...interface{}) *App { // The pos means action constant including // beego.BeforeStatic, beego.BeforeRouter, beego.BeforeExec, beego.AfterExec and beego.FinishRouter. // The bool params is for setting the returnOnOutput value (false allows multiple filters to execute) +// Deprecated: using pkg/, we will delete this in v2.1.0 func InsertFilter(pattern string, pos int, filter FilterFunc, params ...bool) *App { BeeApp.Handlers.InsertFilter(pattern, pos, filter, params...) return BeeApp diff --git a/beego.go b/beego.go index 8ebe0bab..ef93134d 100644 --- a/beego.go +++ b/beego.go @@ -23,15 +23,19 @@ import ( const ( // VERSION represent beego web framework version. + // Deprecated: using pkg/, we will delete this in v2.1.0 VERSION = "1.12.2" // DEV is for develop + // Deprecated: using pkg/, we will delete this in v2.1.0 DEV = "dev" // PROD is for production + // Deprecated: using pkg/, we will delete this in v2.1.0 PROD = "prod" ) // M is Map shortcut +// Deprecated: using pkg/, we will delete this in v2.1.0 type M map[string]interface{} // Hook function to run @@ -44,6 +48,7 @@ var ( // AddAPPStartHook is used to register the hookfunc // The hookfuncs will run in beego.Run() // such as initiating session , starting middleware , building template, starting admin control and so on. +// Deprecated: using pkg/, we will delete this in v2.1.0 func AddAPPStartHook(hf ...hookfunc) { hooks = append(hooks, hf...) } @@ -53,6 +58,7 @@ func AddAPPStartHook(hf ...hookfunc) { // beego.Run("localhost") // beego.Run(":8089") // beego.Run("127.0.0.1:8089") +// Deprecated: using pkg/, we will delete this in v2.1.0 func Run(params ...string) { initBeforeHTTPRun() @@ -73,6 +79,7 @@ func Run(params ...string) { } // RunWithMiddleWares Run beego application with middlewares. +// Deprecated: using pkg/, we will delete this in v2.1.0 func RunWithMiddleWares(addr string, mws ...MiddleWare) { initBeforeHTTPRun() @@ -107,6 +114,7 @@ func initBeforeHTTPRun() { } // TestBeegoInit is for test package init +// Deprecated: using pkg/, we will delete this in v2.1.0 func TestBeegoInit(ap string) { path := filepath.Join(ap, "conf", "app.conf") os.Chdir(ap) @@ -114,6 +122,7 @@ func TestBeegoInit(ap string) { } // InitBeegoBeforeTest is for test package init +// Deprecated: using pkg/, we will delete this in v2.1.0 func InitBeegoBeforeTest(appConfigPath string) { if err := LoadAppConfig(appConfigProvider, appConfigPath); err != nil { panic(err) diff --git a/build_info.go b/build_info.go index c31152ea..896bbdf3 100644 --- a/build_info.go +++ b/build_info.go @@ -15,13 +15,20 @@ package beego var ( + // Deprecated: using pkg/, we will delete this in v2.1.0 BuildVersion string + // Deprecated: using pkg/, we will delete this in v2.1.0 BuildGitRevision string + // Deprecated: using pkg/, we will delete this in v2.1.0 BuildStatus string + // Deprecated: using pkg/, we will delete this in v2.1.0 BuildTag string + // Deprecated: using pkg/, we will delete this in v2.1.0 BuildTime string + // Deprecated: using pkg/, we will delete this in v2.1.0 GoVersion string + // Deprecated: using pkg/, we will delete this in v2.1.0 GitBranch string ) diff --git a/config.go b/config.go index 0c995293..d707542a 100644 --- a/config.go +++ b/config.go @@ -31,6 +31,7 @@ import ( ) // Config is the main struct for BConfig +// Deprecated: using pkg/, we will delete this in v2.1.0 type Config struct { AppName string //Application name RunMode string //Running Mode: dev | prod @@ -49,6 +50,7 @@ type Config struct { } // Listen holds for http and https related config +// Deprecated: using pkg/, we will delete this in v2.1.0 type Listen struct { Graceful bool // Graceful means use graceful module to start the server ServerTimeOut int64 @@ -75,6 +77,7 @@ type Listen struct { } // WebConfig holds web related config +// Deprecated: using pkg/, we will delete this in v2.1.0 type WebConfig struct { AutoRender bool EnableDocs bool @@ -95,6 +98,7 @@ type WebConfig struct { } // SessionConfig holds session related config +// Deprecated: using pkg/, we will delete this in v2.1.0 type SessionConfig struct { SessionOn bool SessionProvider string @@ -111,6 +115,7 @@ type SessionConfig struct { } // LogConfig holds Log related config +// Deprecated: using pkg/, we will delete this in v2.1.0 type LogConfig struct { AccessLogs bool EnableStaticLogs bool //log static files requests default: false @@ -121,12 +126,16 @@ type LogConfig struct { var ( // BConfig is the default config for Application + // Deprecated: using pkg/, we will delete this in v2.1.0 BConfig *Config // AppConfig is the instance of Config, store the config information from file + // Deprecated: using pkg/, we will delete this in v2.1.0 AppConfig *beegoAppConfig // AppPath is the absolute path to the app + // Deprecated: using pkg/, we will delete this in v2.1.0 AppPath string // GlobalSessions is the instance for the session manager + // Deprecated: using pkg/, we will delete this in v2.1.0 GlobalSessions *session.Manager // appConfigPath is the path to the config files @@ -134,6 +143,7 @@ var ( // appConfigProvider is the provider for the config, default is ini appConfigProvider = "ini" // WorkPath is the absolute path to project root directory + // Deprecated: using pkg/, we will delete this in v2.1.0 WorkPath string ) @@ -398,6 +408,7 @@ func assignSingleConfig(p interface{}, ac config.Configer) { } // LoadAppConfig allow developer to apply a config file +// Deprecated: using pkg/, we will delete this in v2.1.0 func LoadAppConfig(adapterName, configPath string) error { absConfigPath, err := filepath.Abs(configPath) if err != nil { @@ -426,6 +437,7 @@ func newAppConfig(appConfigProvider, appConfigPath string) (*beegoAppConfig, err return &beegoAppConfig{ac}, nil } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) Set(key, val string) error { if err := b.innerConfig.Set(BConfig.RunMode+"::"+key, val); err != nil { return b.innerConfig.Set(key, val) @@ -433,6 +445,7 @@ func (b *beegoAppConfig) Set(key, val string) error { return nil } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) String(key string) string { if v := b.innerConfig.String(BConfig.RunMode + "::" + key); v != "" { return v @@ -440,6 +453,7 @@ func (b *beegoAppConfig) String(key string) string { return b.innerConfig.String(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) Strings(key string) []string { if v := b.innerConfig.Strings(BConfig.RunMode + "::" + key); len(v) > 0 { return v @@ -447,6 +461,7 @@ func (b *beegoAppConfig) Strings(key string) []string { return b.innerConfig.Strings(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) Int(key string) (int, error) { if v, err := b.innerConfig.Int(BConfig.RunMode + "::" + key); err == nil { return v, nil @@ -454,6 +469,7 @@ func (b *beegoAppConfig) Int(key string) (int, error) { return b.innerConfig.Int(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) Int64(key string) (int64, error) { if v, err := b.innerConfig.Int64(BConfig.RunMode + "::" + key); err == nil { return v, nil @@ -461,6 +477,7 @@ func (b *beegoAppConfig) Int64(key string) (int64, error) { return b.innerConfig.Int64(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) Bool(key string) (bool, error) { if v, err := b.innerConfig.Bool(BConfig.RunMode + "::" + key); err == nil { return v, nil @@ -468,6 +485,7 @@ func (b *beegoAppConfig) Bool(key string) (bool, error) { return b.innerConfig.Bool(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) Float(key string) (float64, error) { if v, err := b.innerConfig.Float(BConfig.RunMode + "::" + key); err == nil { return v, nil @@ -475,6 +493,7 @@ func (b *beegoAppConfig) Float(key string) (float64, error) { return b.innerConfig.Float(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DefaultString(key string, defaultVal string) string { if v := b.String(key); v != "" { return v @@ -482,6 +501,7 @@ func (b *beegoAppConfig) DefaultString(key string, defaultVal string) string { return defaultVal } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DefaultStrings(key string, defaultVal []string) []string { if v := b.Strings(key); len(v) != 0 { return v @@ -489,6 +509,7 @@ func (b *beegoAppConfig) DefaultStrings(key string, defaultVal []string) []strin return defaultVal } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DefaultInt(key string, defaultVal int) int { if v, err := b.Int(key); err == nil { return v @@ -496,6 +517,7 @@ func (b *beegoAppConfig) DefaultInt(key string, defaultVal int) int { return defaultVal } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DefaultInt64(key string, defaultVal int64) int64 { if v, err := b.Int64(key); err == nil { return v @@ -503,6 +525,7 @@ func (b *beegoAppConfig) DefaultInt64(key string, defaultVal int64) int64 { return defaultVal } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DefaultBool(key string, defaultVal bool) bool { if v, err := b.Bool(key); err == nil { return v @@ -510,6 +533,7 @@ func (b *beegoAppConfig) DefaultBool(key string, defaultVal bool) bool { return defaultVal } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DefaultFloat(key string, defaultVal float64) float64 { if v, err := b.Float(key); err == nil { return v @@ -517,14 +541,17 @@ func (b *beegoAppConfig) DefaultFloat(key string, defaultVal float64) float64 { return defaultVal } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) DIY(key string) (interface{}, error) { return b.innerConfig.DIY(key) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) GetSection(section string) (map[string]string, error) { return b.innerConfig.GetSection(section) } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (b *beegoAppConfig) SaveConfigFile(filename string) error { return b.innerConfig.SaveConfigFile(filename) } diff --git a/controller.go b/controller.go index 0e8853b3..0b4a79a8 100644 --- a/controller.go +++ b/controller.go @@ -35,12 +35,15 @@ import ( var ( // ErrAbort custom error when user stop request handler manually. + // Deprecated: using pkg/, we will delete this in v2.1.0 ErrAbort = errors.New("user stop run") // GlobalControllerRouter store comments with controller. pkgpath+controller:comments + // Deprecated: using pkg/, we will delete this in v2.1.0 GlobalControllerRouter = make(map[string][]ControllerComments) ) // ControllerFilter store the filter for controller +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerFilter struct { Pattern string Pos int @@ -50,6 +53,7 @@ type ControllerFilter struct { } // ControllerFilterComments store the comment for controller level filter +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerFilterComments struct { Pattern string Pos int @@ -59,12 +63,14 @@ type ControllerFilterComments struct { } // ControllerImportComments store the import comment for controller needed +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerImportComments struct { ImportPath string ImportAlias string } // ControllerComments store the comment for the controller method +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerComments struct { Method string Router string @@ -77,6 +83,7 @@ type ControllerComments struct { } // ControllerCommentsSlice implements the sort interface +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerCommentsSlice []ControllerComments func (p ControllerCommentsSlice) Len() int { return len(p) } @@ -85,6 +92,7 @@ func (p ControllerCommentsSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } // Controller defines some basic http request handler operations, such as // http context, template and view, session and xsrf. +// Deprecated: using pkg/, we will delete this in v2.1.0 type Controller struct { // context data Ctx *context.Context @@ -115,6 +123,7 @@ type Controller struct { } // ControllerInterface is an interface to uniform all controller handler. +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerInterface interface { Init(ct *context.Context, controllerName, actionName string, app interface{}) Prepare() @@ -135,6 +144,7 @@ type ControllerInterface interface { } // Init generates default values of controller operations. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Init(ctx *context.Context, controllerName, actionName string, app interface{}) { c.Layout = "" c.TplName = "" @@ -150,42 +160,51 @@ func (c *Controller) Init(ctx *context.Context, controllerName, actionName strin } // Prepare runs after Init before request function execution. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Prepare() {} // Finish runs after request function execution. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Finish() {} // Get adds a request function to handle GET request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Get() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } // Post adds a request function to handle POST request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Post() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } // Delete adds a request function to handle DELETE request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Delete() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } // Put adds a request function to handle PUT request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Put() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } // Head adds a request function to handle HEAD request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Head() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } // Patch adds a request function to handle PATCH request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Patch() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } // Options adds a request function to handle OPTIONS request. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Options() { http.Error(c.Ctx.ResponseWriter, "Method Not Allowed", http.StatusMethodNotAllowed) } @@ -198,6 +217,7 @@ func (c *Controller) Options() { // reflect the message received, excluding some fields described below, // back to the client as the message body of a 200 (OK) response with a // Content-Type of "message/http" (Section 8.3.1 of [RFC7230]). +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Trace() { ts := func(h http.Header) (hs string) { for k, v := range h { @@ -213,6 +233,7 @@ func (c *Controller) Trace() { } // HandlerFunc call function with the name +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) HandlerFunc(fnname string) bool { if v, ok := c.methodMapping[fnname]; ok { v() @@ -222,14 +243,17 @@ func (c *Controller) HandlerFunc(fnname string) bool { } // URLMapping register the internal Controller router. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) URLMapping() {} // Mapping the method to function +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Mapping(method string, fn func()) { c.methodMapping[method] = fn } // Render sends the response with rendered template bytes as text/html type. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Render() error { if !c.EnableRender { return nil @@ -247,12 +271,14 @@ func (c *Controller) Render() error { } // RenderString returns the rendered template string. Do not send out response. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) RenderString() (string, error) { b, e := c.RenderBytes() return string(b), e } // RenderBytes returns the bytes of rendered template string. Do not send out response. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) RenderBytes() ([]byte, error) { buf, err := c.renderTemplate() //if the controller has set layout, then first get the tplName's content set the content to the layout @@ -314,12 +340,14 @@ func (c *Controller) viewPath() string { } // Redirect sends the redirection response to url with status code. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Redirect(url string, code int) { LogAccess(c.Ctx, nil, code) c.Ctx.Redirect(code, url) } // SetData set the data depending on the accepted +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) SetData(data interface{}) { accept := c.Ctx.Input.Header("Accept") switch accept { @@ -333,6 +361,7 @@ func (c *Controller) SetData(data interface{}) { } // Abort stops controller handler and show the error data if code is defined in ErrorMap or code string. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Abort(code string) { status, err := strconv.Atoi(code) if err != nil { @@ -342,6 +371,7 @@ func (c *Controller) Abort(code string) { } // CustomAbort stops controller handler and show the error data, it's similar Aborts, but support status code and body. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) CustomAbort(status int, body string) { // first panic from ErrorMaps, it is user defined error functions. if _, ok := ErrorMaps[body]; ok { @@ -355,12 +385,14 @@ func (c *Controller) CustomAbort(status int, body string) { } // StopRun makes panic of USERSTOPRUN error and go to recover function if defined. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) StopRun() { panic(ErrAbort) } // URLFor does another controller handler in this request function. // it goes to this controller method if endpoint is not clear. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) URLFor(endpoint string, values ...interface{}) string { if len(endpoint) == 0 { return "" @@ -372,6 +404,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string { } // ServeJSON sends a json response with encoding charset. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) ServeJSON(encoding ...bool) { var ( hasIndent = BConfig.RunMode != PROD @@ -382,23 +415,27 @@ func (c *Controller) ServeJSON(encoding ...bool) { } // ServeJSONP sends a jsonp response. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) ServeJSONP() { hasIndent := BConfig.RunMode != PROD c.Ctx.Output.JSONP(c.Data["jsonp"], hasIndent) } // ServeXML sends xml response. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) ServeXML() { hasIndent := BConfig.RunMode != PROD c.Ctx.Output.XML(c.Data["xml"], hasIndent) } // ServeYAML sends yaml response. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) ServeYAML() { c.Ctx.Output.YAML(c.Data["yaml"]) } // ServeFormatted serve YAML, XML OR JSON, depending on the value of the Accept header +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) ServeFormatted(encoding ...bool) { hasIndent := BConfig.RunMode != PROD hasEncoding := len(encoding) > 0 && encoding[0] @@ -406,6 +443,7 @@ func (c *Controller) ServeFormatted(encoding ...bool) { } // Input returns the input data map from POST or PUT request body and query string. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) Input() url.Values { if c.Ctx.Request.Form == nil { c.Ctx.Request.ParseForm() @@ -414,11 +452,13 @@ func (c *Controller) Input() url.Values { } // ParseForm maps input data map to obj struct. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) ParseForm(obj interface{}) error { return ParseForm(c.Input(), obj) } // GetString returns the input value by key string or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetString(key string, def ...string) string { if v := c.Ctx.Input.Query(key); v != "" { return v @@ -431,6 +471,7 @@ func (c *Controller) GetString(key string, def ...string) string { // GetStrings returns the input string slice by key string or the default value while it's present and input is blank // it's designed for multi-value input field such as checkbox(input[type=checkbox]), multi-selection. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetStrings(key string, def ...[]string) []string { var defv []string if len(def) > 0 { @@ -447,6 +488,7 @@ func (c *Controller) GetStrings(key string, def ...[]string) []string { } // GetInt returns input as an int or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetInt(key string, def ...int) (int, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -456,6 +498,7 @@ func (c *Controller) GetInt(key string, def ...int) (int, error) { } // GetInt8 return input as an int8 or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetInt8(key string, def ...int8) (int8, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -466,6 +509,7 @@ func (c *Controller) GetInt8(key string, def ...int8) (int8, error) { } // GetUint8 return input as an uint8 or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetUint8(key string, def ...uint8) (uint8, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -476,6 +520,7 @@ func (c *Controller) GetUint8(key string, def ...uint8) (uint8, error) { } // GetInt16 returns input as an int16 or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetInt16(key string, def ...int16) (int16, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -486,6 +531,7 @@ func (c *Controller) GetInt16(key string, def ...int16) (int16, error) { } // GetUint16 returns input as an uint16 or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetUint16(key string, def ...uint16) (uint16, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -496,6 +542,7 @@ func (c *Controller) GetUint16(key string, def ...uint16) (uint16, error) { } // GetInt32 returns input as an int32 or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetInt32(key string, def ...int32) (int32, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -506,6 +553,7 @@ func (c *Controller) GetInt32(key string, def ...int32) (int32, error) { } // GetUint32 returns input as an uint32 or the default value while it's present and input is blank +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetUint32(key string, def ...uint32) (uint32, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -516,6 +564,7 @@ func (c *Controller) GetUint32(key string, def ...uint32) (uint32, error) { } // GetInt64 returns input value as int64 or the default value while it's present and input is blank. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetInt64(key string, def ...int64) (int64, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -525,6 +574,7 @@ func (c *Controller) GetInt64(key string, def ...int64) (int64, error) { } // GetUint64 returns input value as uint64 or the default value while it's present and input is blank. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetUint64(key string, def ...uint64) (uint64, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -534,6 +584,7 @@ func (c *Controller) GetUint64(key string, def ...uint64) (uint64, error) { } // GetBool returns input value as bool or the default value while it's present and input is blank. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetBool(key string, def ...bool) (bool, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -543,6 +594,7 @@ func (c *Controller) GetBool(key string, def ...bool) (bool, error) { } // GetFloat returns input value as float64 or the default value while it's present and input is blank. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetFloat(key string, def ...float64) (float64, error) { strv := c.Ctx.Input.Query(key) if len(strv) == 0 && len(def) > 0 { @@ -553,6 +605,7 @@ func (c *Controller) GetFloat(key string, def ...float64) (float64, error) { // GetFile returns the file data in file upload field named as key. // it returns the first one of multi-uploaded files. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, error) { return c.Ctx.Request.FormFile(key) } @@ -584,6 +637,7 @@ func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, // return // } // } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetFiles(key string) ([]*multipart.FileHeader, error) { if files, ok := c.Ctx.Request.MultipartForm.File[key]; ok { return files, nil @@ -593,6 +647,7 @@ func (c *Controller) GetFiles(key string) ([]*multipart.FileHeader, error) { // SaveToFile saves uploaded file to new path. // it only operates the first one of mutil-upload form file field. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) SaveToFile(fromfile, tofile string) error { file, _, err := c.Ctx.Request.FormFile(fromfile) if err != nil { @@ -609,6 +664,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error { } // StartSession starts session and load old session data info this controller. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) StartSession() session.Store { if c.CruSession == nil { c.CruSession = c.Ctx.Input.CruSession @@ -617,6 +673,7 @@ func (c *Controller) StartSession() session.Store { } // SetSession puts value into session. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) SetSession(name interface{}, value interface{}) { if c.CruSession == nil { c.StartSession() @@ -625,6 +682,7 @@ func (c *Controller) SetSession(name interface{}, value interface{}) { } // GetSession gets value from session. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetSession(name interface{}) interface{} { if c.CruSession == nil { c.StartSession() @@ -633,6 +691,7 @@ func (c *Controller) GetSession(name interface{}) interface{} { } // DelSession removes value from session. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) DelSession(name interface{}) { if c.CruSession == nil { c.StartSession() @@ -642,6 +701,7 @@ func (c *Controller) DelSession(name interface{}) { // SessionRegenerateID regenerates session id for this session. // the session data have no changes. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) SessionRegenerateID() { if c.CruSession != nil { c.CruSession.SessionRelease(c.Ctx.ResponseWriter) @@ -651,6 +711,7 @@ func (c *Controller) SessionRegenerateID() { } // DestroySession cleans session data and session cookie. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) DestroySession() { c.Ctx.Input.CruSession.Flush() c.Ctx.Input.CruSession = nil @@ -658,21 +719,25 @@ func (c *Controller) DestroySession() { } // IsAjax returns this request is ajax or not. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) IsAjax() bool { return c.Ctx.Input.IsAjax() } // GetSecureCookie returns decoded cookie value from encoded browser cookie values. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetSecureCookie(Secret, key string) (string, bool) { return c.Ctx.GetSecureCookie(Secret, key) } // SetSecureCookie puts value into cookie after encoded the value. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) SetSecureCookie(Secret, name, value string, others ...interface{}) { c.Ctx.SetSecureCookie(Secret, name, value, others...) } // XSRFToken creates a CSRF token string and returns. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) XSRFToken() string { if c._xsrfToken == "" { expire := int64(BConfig.WebConfig.XSRFExpire) @@ -687,6 +752,7 @@ func (c *Controller) XSRFToken() string { // 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". +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) CheckXSRFCookie() bool { if !c.EnableXSRF { return true @@ -695,12 +761,14 @@ func (c *Controller) CheckXSRFCookie() bool { } // XSRFFormHTML writes an input field contains xsrf token value. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) XSRFFormHTML() string { return `` } // GetControllerAndAction gets the executing controller name and action name. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *Controller) GetControllerAndAction() (string, string) { return c.controllerName, c.actionName } diff --git a/doc.go b/doc.go index 8825bd29..72284c67 100644 --- a/doc.go +++ b/doc.go @@ -13,5 +13,7 @@ beego is inspired by Tornado, Sinatra and Flask with the added benefit of some G } more information: http://beego.me + +Deprecated: using pkg/, we will delete this in v2.1.0 */ package beego diff --git a/error.go b/error.go index f268f723..40eea5fa 100644 --- a/error.go +++ b/error.go @@ -205,6 +205,7 @@ type errorInfo struct { // ErrorMaps holds map of http handlers for each error string. // there is 10 kinds default error(40x and 50x) +// Deprecated: using pkg/, we will delete this in v2.1.0 var ErrorMaps = make(map[string]*errorInfo, 10) // show 401 unauthorized error. @@ -387,6 +388,7 @@ func responseError(rw http.ResponseWriter, r *http.Request, errCode int, errCont // usage: // beego.ErrorHandler("404",NotFound) // beego.ErrorHandler("500",InternalServerError) +// Deprecated: using pkg/, we will delete this in v2.1.0 func ErrorHandler(code string, h http.HandlerFunc) *App { ErrorMaps[code] = &errorInfo{ errorType: errorTypeHandler, @@ -399,6 +401,7 @@ func ErrorHandler(code string, h http.HandlerFunc) *App { // ErrorController registers ControllerInterface to each http err code string. // usage: // beego.ErrorController(&controllers.ErrorController{}) +// Deprecated: using pkg/, we will delete this in v2.1.0 func ErrorController(c ControllerInterface) *App { reflectVal := reflect.ValueOf(c) rt := reflectVal.Type() @@ -418,6 +421,7 @@ func ErrorController(c ControllerInterface) *App { } // Exception Write HttpStatus with errCode and Exec error handler if exist. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Exception(errCode uint64, ctx *context.Context) { exception(strconv.FormatUint(errCode, 10), ctx) } diff --git a/filter.go b/filter.go index 9cc6e913..8596d288 100644 --- a/filter.go +++ b/filter.go @@ -17,11 +17,13 @@ package beego import "github.com/astaxie/beego/context" // FilterFunc defines a filter function which is invoked before the controller handler is executed. +// Deprecated: using pkg/, we will delete this in v2.1.0 type FilterFunc func(*context.Context) // FilterRouter defines a filter operation which is invoked before the controller handler is executed. // It can match the URL against a pattern, and execute a filter function // when a request with a matching URL arrives. +// Deprecated: using pkg/, we will delete this in v2.1.0 type FilterRouter struct { filterFunc FilterFunc tree *Tree @@ -33,6 +35,7 @@ type FilterRouter struct { // ValidRouter checks if the current request is matched by this filter. // If the request is matched, the values of the URL parameters defined // by the filter pattern are also returned. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (f *FilterRouter) ValidRouter(url string, ctx *context.Context) bool { isOk := f.tree.Match(url, ctx) if isOk != nil { diff --git a/flash.go b/flash.go index a6485a17..fe3fb974 100644 --- a/flash.go +++ b/flash.go @@ -21,11 +21,13 @@ import ( ) // FlashData is a tools to maintain data when using across request. +// Deprecated: using pkg/, we will delete this in v2.1.0 type FlashData struct { Data map[string]string } // NewFlash return a new empty FlashData struct. +// Deprecated: using pkg/, we will delete this in v2.1.0 func NewFlash() *FlashData { return &FlashData{ Data: make(map[string]string), @@ -33,6 +35,7 @@ func NewFlash() *FlashData { } // Set message to flash +// Deprecated: using pkg/, we will delete this in v2.1.0 func (fd *FlashData) Set(key string, msg string, args ...interface{}) { if len(args) == 0 { fd.Data[key] = msg @@ -42,6 +45,7 @@ func (fd *FlashData) Set(key string, msg string, args ...interface{}) { } // Success writes success message to flash. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (fd *FlashData) Success(msg string, args ...interface{}) { if len(args) == 0 { fd.Data["success"] = msg @@ -51,6 +55,7 @@ func (fd *FlashData) Success(msg string, args ...interface{}) { } // Notice writes notice message to flash. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (fd *FlashData) Notice(msg string, args ...interface{}) { if len(args) == 0 { fd.Data["notice"] = msg @@ -60,6 +65,7 @@ func (fd *FlashData) Notice(msg string, args ...interface{}) { } // Warning writes warning message to flash. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (fd *FlashData) Warning(msg string, args ...interface{}) { if len(args) == 0 { fd.Data["warning"] = msg @@ -69,6 +75,7 @@ func (fd *FlashData) Warning(msg string, args ...interface{}) { } // Error writes error message to flash. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (fd *FlashData) Error(msg string, args ...interface{}) { if len(args) == 0 { fd.Data["error"] = msg @@ -79,6 +86,7 @@ func (fd *FlashData) Error(msg string, args ...interface{}) { // Store does the saving operation of flash data. // the data are encoded and saved in cookie. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (fd *FlashData) Store(c *Controller) { c.Data["flash"] = fd.Data var flashValue string @@ -89,6 +97,7 @@ func (fd *FlashData) Store(c *Controller) { } // ReadFromRequest parsed flash data from encoded values in cookie. +// Deprecated: using pkg/, we will delete this in v2.1.0 func ReadFromRequest(c *Controller) *FlashData { flash := NewFlash() if cookie, err := c.Ctx.Request.Cookie(BConfig.WebConfig.FlashName); err == nil { diff --git a/fs.go b/fs.go index 41cc6f6e..3300813d 100644 --- a/fs.go +++ b/fs.go @@ -6,9 +6,11 @@ import ( "path/filepath" ) +// Deprecated: using pkg/, we will delete this in v2.1.0 type FileSystem struct { } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (d FileSystem) Open(name string) (http.File, error) { return os.Open(name) } @@ -16,6 +18,7 @@ func (d FileSystem) Open(name string) (http.File, error) { // Walk walks the file tree rooted at root in filesystem, calling walkFn for each file or // directory in the tree, including root. All errors that arise visiting files // and directories are filtered by walkFn. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error { f, err := fs.Open(root) diff --git a/namespace.go b/namespace.go index 4952c9d5..a6962994 100644 --- a/namespace.go +++ b/namespace.go @@ -24,15 +24,18 @@ import ( type namespaceCond func(*beecontext.Context) bool // LinkNamespace used as link action +// Deprecated: using pkg/, we will delete this in v2.1.0 type LinkNamespace func(*Namespace) // Namespace is store all the info +// Deprecated: using pkg/, we will delete this in v2.1.0 type Namespace struct { prefix string handlers *ControllerRegister } // NewNamespace get new Namespace +// Deprecated: using pkg/, we will delete this in v2.1.0 func NewNamespace(prefix string, params ...LinkNamespace) *Namespace { ns := &Namespace{ prefix: prefix, @@ -54,6 +57,7 @@ func NewNamespace(prefix string, params ...LinkNamespace) *Namespace { // return false // }) // Cond as the first filter +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Cond(cond namespaceCond) *Namespace { fn := func(ctx *beecontext.Context) { if !cond(ctx) { @@ -83,6 +87,7 @@ func (n *Namespace) Cond(cond namespaceCond) *Namespace { // ctx.Redirect(302, "/login") // } // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Filter(action string, filter ...FilterFunc) *Namespace { var a int if action == "before" { @@ -98,6 +103,7 @@ func (n *Namespace) Filter(action string, filter ...FilterFunc) *Namespace { // Router same as beego.Rourer // refer: https://godoc.org/github.com/astaxie/beego#Router +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Router(rootpath string, c ControllerInterface, mappingMethods ...string) *Namespace { n.handlers.Add(rootpath, c, mappingMethods...) return n @@ -105,6 +111,7 @@ func (n *Namespace) Router(rootpath string, c ControllerInterface, mappingMethod // AutoRouter same as beego.AutoRouter // refer: https://godoc.org/github.com/astaxie/beego#AutoRouter +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) AutoRouter(c ControllerInterface) *Namespace { n.handlers.AddAuto(c) return n @@ -112,6 +119,7 @@ func (n *Namespace) AutoRouter(c ControllerInterface) *Namespace { // AutoPrefix same as beego.AutoPrefix // refer: https://godoc.org/github.com/astaxie/beego#AutoPrefix +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) AutoPrefix(prefix string, c ControllerInterface) *Namespace { n.handlers.AddAutoPrefix(prefix, c) return n @@ -119,6 +127,7 @@ func (n *Namespace) AutoPrefix(prefix string, c ControllerInterface) *Namespace // Get same as beego.Get // refer: https://godoc.org/github.com/astaxie/beego#Get +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace { n.handlers.Get(rootpath, f) return n @@ -126,6 +135,7 @@ func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace { // Post same as beego.Post // refer: https://godoc.org/github.com/astaxie/beego#Post +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace { n.handlers.Post(rootpath, f) return n @@ -133,6 +143,7 @@ func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace { // Delete same as beego.Delete // refer: https://godoc.org/github.com/astaxie/beego#Delete +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace { n.handlers.Delete(rootpath, f) return n @@ -140,6 +151,7 @@ func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace { // Put same as beego.Put // refer: https://godoc.org/github.com/astaxie/beego#Put +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace { n.handlers.Put(rootpath, f) return n @@ -147,6 +159,7 @@ func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace { // Head same as beego.Head // refer: https://godoc.org/github.com/astaxie/beego#Head +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace { n.handlers.Head(rootpath, f) return n @@ -154,6 +167,7 @@ func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace { // Options same as beego.Options // refer: https://godoc.org/github.com/astaxie/beego#Options +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace { n.handlers.Options(rootpath, f) return n @@ -161,6 +175,7 @@ func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace { // Patch same as beego.Patch // refer: https://godoc.org/github.com/astaxie/beego#Patch +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace { n.handlers.Patch(rootpath, f) return n @@ -168,6 +183,7 @@ func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace { // Any same as beego.Any // refer: https://godoc.org/github.com/astaxie/beego#Any +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace { n.handlers.Any(rootpath, f) return n @@ -175,6 +191,7 @@ func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace { // Handler same as beego.Handler // refer: https://godoc.org/github.com/astaxie/beego#Handler +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Handler(rootpath string, h http.Handler) *Namespace { n.handlers.Handler(rootpath, h) return n @@ -182,6 +199,7 @@ func (n *Namespace) Handler(rootpath string, h http.Handler) *Namespace { // Include add include class // refer: https://godoc.org/github.com/astaxie/beego#Include +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Include(cList ...ControllerInterface) *Namespace { n.handlers.Include(cList...) return n @@ -204,6 +222,7 @@ func (n *Namespace) Include(cList ...ControllerInterface) *Namespace { // ctx.Output.Body([]byte("crminfo")) // }), //) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (n *Namespace) Namespace(ns ...*Namespace) *Namespace { for _, ni := range ns { for k, v := range ni.handlers.routers { @@ -233,6 +252,7 @@ func (n *Namespace) Namespace(ns ...*Namespace) *Namespace { // AddNamespace register Namespace into beego.Handler // support multi Namespace +// Deprecated: using pkg/, we will delete this in v2.1.0 func AddNamespace(nl ...*Namespace) { for _, n := range nl { for k, v := range n.handlers.routers { @@ -276,6 +296,7 @@ func addPrefix(t *Tree, prefix string) { } // NSCond is Namespace Condition +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSCond(cond namespaceCond) LinkNamespace { return func(ns *Namespace) { ns.Cond(cond) @@ -283,6 +304,7 @@ func NSCond(cond namespaceCond) LinkNamespace { } // NSBefore Namespace BeforeRouter filter +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSBefore(filterList ...FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Filter("before", filterList...) @@ -290,6 +312,7 @@ func NSBefore(filterList ...FilterFunc) LinkNamespace { } // NSAfter add Namespace FinishRouter filter +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSAfter(filterList ...FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Filter("after", filterList...) @@ -297,6 +320,7 @@ func NSAfter(filterList ...FilterFunc) LinkNamespace { } // NSInclude Namespace Include ControllerInterface +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSInclude(cList ...ControllerInterface) LinkNamespace { return func(ns *Namespace) { ns.Include(cList...) @@ -304,6 +328,7 @@ func NSInclude(cList ...ControllerInterface) LinkNamespace { } // NSRouter call Namespace Router +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) LinkNamespace { return func(ns *Namespace) { ns.Router(rootpath, c, mappingMethods...) @@ -311,6 +336,7 @@ func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) } // NSGet call Namespace Get +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSGet(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Get(rootpath, f) @@ -318,6 +344,7 @@ func NSGet(rootpath string, f FilterFunc) LinkNamespace { } // NSPost call Namespace Post +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSPost(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Post(rootpath, f) @@ -325,6 +352,7 @@ func NSPost(rootpath string, f FilterFunc) LinkNamespace { } // NSHead call Namespace Head +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSHead(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Head(rootpath, f) @@ -332,6 +360,7 @@ func NSHead(rootpath string, f FilterFunc) LinkNamespace { } // NSPut call Namespace Put +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSPut(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Put(rootpath, f) @@ -339,6 +368,7 @@ func NSPut(rootpath string, f FilterFunc) LinkNamespace { } // NSDelete call Namespace Delete +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSDelete(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Delete(rootpath, f) @@ -346,6 +376,7 @@ func NSDelete(rootpath string, f FilterFunc) LinkNamespace { } // NSAny call Namespace Any +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSAny(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Any(rootpath, f) @@ -353,6 +384,7 @@ func NSAny(rootpath string, f FilterFunc) LinkNamespace { } // NSOptions call Namespace Options +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSOptions(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Options(rootpath, f) @@ -360,6 +392,7 @@ func NSOptions(rootpath string, f FilterFunc) LinkNamespace { } // NSPatch call Namespace Patch +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSPatch(rootpath string, f FilterFunc) LinkNamespace { return func(ns *Namespace) { ns.Patch(rootpath, f) @@ -367,6 +400,7 @@ func NSPatch(rootpath string, f FilterFunc) LinkNamespace { } // NSAutoRouter call Namespace AutoRouter +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSAutoRouter(c ControllerInterface) LinkNamespace { return func(ns *Namespace) { ns.AutoRouter(c) @@ -374,6 +408,7 @@ func NSAutoRouter(c ControllerInterface) LinkNamespace { } // NSAutoPrefix call Namespace AutoPrefix +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSAutoPrefix(prefix string, c ControllerInterface) LinkNamespace { return func(ns *Namespace) { ns.AutoPrefix(prefix, c) @@ -381,6 +416,7 @@ func NSAutoPrefix(prefix string, c ControllerInterface) LinkNamespace { } // NSNamespace add sub Namespace +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSNamespace(prefix string, params ...LinkNamespace) LinkNamespace { return func(ns *Namespace) { n := NewNamespace(prefix, params...) @@ -389,6 +425,7 @@ func NSNamespace(prefix string, params ...LinkNamespace) LinkNamespace { } // NSHandler add handler +// Deprecated: using pkg/, we will delete this in v2.1.0 func NSHandler(rootpath string, h http.Handler) LinkNamespace { return func(ns *Namespace) { ns.Handler(rootpath, h) diff --git a/policy.go b/policy.go index ab23f927..358a0539 100644 --- a/policy.go +++ b/policy.go @@ -21,9 +21,11 @@ import ( ) // PolicyFunc defines a policy function which is invoked before the controller handler is executed. +// Deprecated: using pkg/, we will delete this in v2.1.0 type PolicyFunc func(*context.Context) // FindPolicy Find Router info for URL +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) FindPolicy(cont *context.Context) []PolicyFunc { var urlPath = cont.Input.URL() if !BConfig.RouterCaseSensitive { @@ -72,6 +74,7 @@ func (p *ControllerRegister) addToPolicy(method, pattern string, r ...PolicyFunc } // Policy Register new policy in beego +// Deprecated: using pkg/, we will delete this in v2.1.0 func Policy(pattern, method string, policy ...PolicyFunc) { BeeApp.Handlers.addToPolicy(method, pattern, policy...) } diff --git a/router.go b/router.go index 92316480..1be495ab 100644 --- a/router.go +++ b/router.go @@ -51,6 +51,7 @@ const ( var ( // HTTPMETHOD list the supported http methods. + // Deprecated: using pkg/, we will delete this in v2.1.0 HTTPMETHOD = map[string]bool{ "GET": true, "POST": true, @@ -80,10 +81,12 @@ var ( urlPlaceholder = "{{placeholder}}" // DefaultAccessLogFilter will skip the accesslog if return true + // Deprecated: using pkg/, we will delete this in v2.1.0 DefaultAccessLogFilter FilterHandler = &logFilter{} ) // FilterHandler is an interface for +// Deprecated: using pkg/, we will delete this in v2.1.0 type FilterHandler interface { Filter(*beecontext.Context) bool } @@ -92,6 +95,7 @@ type FilterHandler interface { type logFilter struct { } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (l *logFilter) Filter(ctx *beecontext.Context) bool { requestPath := path.Clean(ctx.Request.URL.Path) if requestPath == "/favicon.ico" || requestPath == "/robots.txt" { @@ -106,6 +110,7 @@ func (l *logFilter) Filter(ctx *beecontext.Context) bool { } // ExceptMethodAppend to append a slice's value into "exceptMethod", for controller's methods shouldn't reflect to AutoRouter +// Deprecated: using pkg/, we will delete this in v2.1.0 func ExceptMethodAppend(action string) { exceptMethod = append(exceptMethod, action) } @@ -122,11 +127,13 @@ type ControllerInfo struct { methodParams []*param.MethodParam } +// Deprecated: using pkg/, we will delete this in v2.1.0 func (c *ControllerInfo) GetPattern() string { return c.pattern } // ControllerRegister containers registered router rules, controller handlers and filters. +// Deprecated: using pkg/, we will delete this in v2.1.0 type ControllerRegister struct { routers map[string]*Tree enablePolicy bool @@ -137,6 +144,7 @@ type ControllerRegister struct { } // NewControllerRegister returns a new ControllerRegister. +// Deprecated: using pkg/, we will delete this in v2.1.0 func NewControllerRegister() *ControllerRegister { return &ControllerRegister{ routers: make(map[string]*Tree), @@ -159,6 +167,7 @@ func NewControllerRegister() *ControllerRegister { // Add("/api/delete",&RestController{},"delete:DeleteFood") // Add("/api",&RestController{},"get,post:ApiFunc" // Add("/simple",&SimpleController{},"get:GetFunc;post:PostFunc") +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Add(pattern string, c ControllerInterface, mappingMethods ...string) { p.addWithMethodParams(pattern, c, nil, mappingMethods...) } @@ -251,6 +260,7 @@ func (p *ControllerRegister) addToRouter(method, pattern string, r *ControllerIn // Include only when the Runmode is dev will generate router file in the router/auto.go from the controller // Include(&BankAccount{}, &OrderController{},&RefundController{},&ReceiptController{}) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Include(cList ...ControllerInterface) { if BConfig.RunMode == DEV { skip := make(map[string]bool, 10) @@ -313,11 +323,13 @@ func (p *ControllerRegister) Include(cList ...ControllerInterface) { // ctx := p.GetContext() // ctx.Reset(w, q) // defer p.GiveBackContext(ctx) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) GetContext() *beecontext.Context { return p.pool.Get().(*beecontext.Context) } // GiveBackContext put the ctx into pool so that it could be reuse +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) GiveBackContext(ctx *beecontext.Context) { // clear input cached data ctx.Input.Clear() @@ -331,6 +343,7 @@ func (p *ControllerRegister) GiveBackContext(ctx *beecontext.Context) { // Get("/", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Get(pattern string, f FilterFunc) { p.AddMethod("get", pattern, f) } @@ -340,6 +353,7 @@ func (p *ControllerRegister) Get(pattern string, f FilterFunc) { // Post("/api", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Post(pattern string, f FilterFunc) { p.AddMethod("post", pattern, f) } @@ -349,6 +363,7 @@ func (p *ControllerRegister) Post(pattern string, f FilterFunc) { // Put("/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Put(pattern string, f FilterFunc) { p.AddMethod("put", pattern, f) } @@ -358,6 +373,7 @@ func (p *ControllerRegister) Put(pattern string, f FilterFunc) { // Delete("/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Delete(pattern string, f FilterFunc) { p.AddMethod("delete", pattern, f) } @@ -367,6 +383,7 @@ func (p *ControllerRegister) Delete(pattern string, f FilterFunc) { // Head("/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Head(pattern string, f FilterFunc) { p.AddMethod("head", pattern, f) } @@ -376,6 +393,7 @@ func (p *ControllerRegister) Head(pattern string, f FilterFunc) { // Patch("/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Patch(pattern string, f FilterFunc) { p.AddMethod("patch", pattern, f) } @@ -385,6 +403,7 @@ func (p *ControllerRegister) Patch(pattern string, f FilterFunc) { // Options("/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Options(pattern string, f FilterFunc) { p.AddMethod("options", pattern, f) } @@ -394,6 +413,7 @@ func (p *ControllerRegister) Options(pattern string, f FilterFunc) { // Any("/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Any(pattern string, f FilterFunc) { p.AddMethod("*", pattern, f) } @@ -403,6 +423,7 @@ func (p *ControllerRegister) Any(pattern string, f FilterFunc) { // AddMethod("get","/api/:id", func(ctx *context.Context){ // ctx.Output.Body("hello world") // }) +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) { method = strings.ToUpper(method) if method != "*" && !HTTPMETHOD[method] { @@ -433,6 +454,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) { } // Handler add user defined Handler +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) Handler(pattern string, h http.Handler, options ...interface{}) { route := &ControllerInfo{} route.pattern = pattern @@ -453,6 +475,7 @@ func (p *ControllerRegister) Handler(pattern string, h http.Handler, options ... // MainController has method List and Page. // visit the url /main/list to execute List function // /main/page to execute Page function. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) AddAuto(c ControllerInterface) { p.AddAutoPrefix("/", c) } @@ -462,6 +485,7 @@ func (p *ControllerRegister) AddAuto(c ControllerInterface) { // MainController has method List and Page. // visit the url /admin/main/list to execute List function // /admin/main/page to execute Page function. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) AddAutoPrefix(prefix string, c ControllerInterface) { reflectVal := reflect.ValueOf(c) rt := reflectVal.Type() @@ -492,6 +516,7 @@ func (p *ControllerRegister) AddAutoPrefix(prefix string, c ControllerInterface) // params is for: // 1. setting the returnOnOutput value (false allows multiple filters to execute) // 2. determining whether or not params need to be reset. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) InsertFilter(pattern string, pos int, filter FilterFunc, params ...bool) error { mr := &FilterRouter{ tree: NewTree(), @@ -526,6 +551,7 @@ func (p *ControllerRegister) insertFilterRouter(pos int, mr *FilterRouter) (err // URLFor does another controller handler in this request function. // it can access any controller method. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) URLFor(endpoint string, values ...interface{}) string { paths := strings.Split(endpoint, ".") if len(paths) <= 1 { @@ -695,6 +721,7 @@ func (p *ControllerRegister) execFilter(context *beecontext.Context, urlPath str } // Implement http.Handler interface. +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request) { startTime := time.Now() var ( @@ -993,6 +1020,7 @@ func (p *ControllerRegister) handleParamResponse(context *beecontext.Context, ex } // FindRouter Find Router info for URL +// Deprecated: using pkg/, we will delete this in v2.1.0 func (p *ControllerRegister) FindRouter(context *beecontext.Context) (routerInfo *ControllerInfo, isFind bool) { var urlPath = context.Input.URL() if !BConfig.RouterCaseSensitive { @@ -1020,6 +1048,7 @@ func toURL(params map[string]string) string { } // LogAccess logging info HTTP Access +// Deprecated: using pkg/, we will delete this in v2.1.0 func LogAccess(ctx *beecontext.Context, startTime *time.Time, statusCode int) { // Skip logging if AccessLogs config is false if !BConfig.Log.AccessLogs { diff --git a/template.go b/template.go index 59875be7..69b178ca 100644 --- a/template.go +++ b/template.go @@ -47,6 +47,7 @@ var ( // ExecuteTemplate applies the template with name to the specified data object, // writing the output to wr. // A template will be executed safely in parallel. +// Deprecated: using pkg/, we will delete this in v2.1.0 func ExecuteTemplate(wr io.Writer, name string, data interface{}) error { return ExecuteViewPathTemplate(wr, name, BConfig.WebConfig.ViewsPath, data) } @@ -54,6 +55,7 @@ func ExecuteTemplate(wr io.Writer, name string, data interface{}) error { // ExecuteViewPathTemplate applies the template with name and from specific viewPath to the specified data object, // writing the output to wr. // A template will be executed safely in parallel. +// Deprecated: using pkg/, we will delete this in v2.1.0 func ExecuteViewPathTemplate(wr io.Writer, name string, viewPath string, data interface{}) error { if BConfig.RunMode == DEV { templatesLock.RLock() @@ -143,6 +145,7 @@ func (tf *templateFile) visit(paths string, f os.FileInfo, err error) error { } // HasTemplateExt return this path contains supported template extension of beego or not. +// Deprecated: using pkg/, we will delete this in v2.1.0 func HasTemplateExt(paths string) bool { for _, v := range beeTemplateExt { if strings.HasSuffix(paths, "."+v) { @@ -153,6 +156,7 @@ func HasTemplateExt(paths string) bool { } // AddTemplateExt add new extension for template. +// Deprecated: using pkg/, we will delete this in v2.1.0 func AddTemplateExt(ext string) { for _, v := range beeTemplateExt { if v == ext { @@ -165,6 +169,7 @@ func AddTemplateExt(ext string) { // AddViewPath adds a new path to the supported view paths. //Can later be used by setting a controller ViewPath to this folder //will panic if called after beego.Run() +// Deprecated: using pkg/, we will delete this in v2.1.0 func AddViewPath(viewPath string) error { if beeViewPathTemplateLocked { if _, exist := beeViewPathTemplates[viewPath]; exist { @@ -182,6 +187,7 @@ func lockViewPaths() { // BuildTemplate will build all template files in a directory. // it makes beego can render any template file in view directory. +// Deprecated: using pkg/, we will delete this in v2.1.0 func BuildTemplate(dir string, files ...string) error { var err error fs := beeTemplateFS() @@ -363,11 +369,13 @@ func defaultFSFunc() http.FileSystem { } // SetTemplateFSFunc set default filesystem function +// Deprecated: using pkg/, we will delete this in v2.1.0 func SetTemplateFSFunc(fnt templateFSFunc) { beeTemplateFS = fnt } // SetViewsPath sets view directory path in beego application. +// Deprecated: using pkg/, we will delete this in v2.1.0 func SetViewsPath(path string) *App { BConfig.WebConfig.ViewsPath = path return BeeApp @@ -375,6 +383,7 @@ func SetViewsPath(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". +// Deprecated: using pkg/, we will delete this in v2.1.0 func SetStaticPath(url string, path string) *App { if !strings.HasPrefix(url, "/") { url = "/" + url @@ -387,6 +396,7 @@ func SetStaticPath(url string, path string) *App { } // DelStaticPath removes the static folder setting in this url pattern in beego application. +// Deprecated: using pkg/, we will delete this in v2.1.0 func DelStaticPath(url string) *App { if !strings.HasPrefix(url, "/") { url = "/" + url @@ -399,6 +409,7 @@ func DelStaticPath(url string) *App { } // AddTemplateEngine add a new templatePreProcessor which support extension +// Deprecated: using pkg/, we will delete this in v2.1.0 func AddTemplateEngine(extension string, fn templatePreProcessor) *App { AddTemplateExt(extension) beeTemplateEngines[extension] = fn diff --git a/templatefunc.go b/templatefunc.go index 6f02b8d6..9e7c42fc 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -35,6 +35,7 @@ const ( ) // Substr returns the substr from start to length. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Substr(s string, start, length int) string { bt := []rune(s) if start < 0 { @@ -53,6 +54,7 @@ func Substr(s string, start, length int) string { } // HTML2str returns escaping text convert from html. +// Deprecated: using pkg/, we will delete this in v2.1.0 func HTML2str(html string) string { re := regexp.MustCompile(`\<[\S\s]+?\>`) @@ -76,6 +78,7 @@ func HTML2str(html string) string { } // DateFormat takes a time and a layout string and returns a string with the formatted date. Used by the template parser as "dateformat" +// Deprecated: using pkg/, we will delete this in v2.1.0 func DateFormat(t time.Time, layout string) (datestring string) { datestring = t.Format(layout) return @@ -123,6 +126,7 @@ var datePatterns = []string{ } // DateParse Parse Date use PHP time format. +// Deprecated: using pkg/, we will delete this in v2.1.0 func DateParse(dateString, format string) (time.Time, error) { replacer := strings.NewReplacer(datePatterns...) format = replacer.Replace(format) @@ -130,6 +134,7 @@ func DateParse(dateString, format string) (time.Time, error) { } // Date takes a PHP like date func to Go's time format. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Date(t time.Time, format string) string { replacer := strings.NewReplacer(datePatterns...) format = replacer.Replace(format) @@ -138,6 +143,7 @@ func Date(t time.Time, format string) string { // 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". +// Deprecated: using pkg/, we will delete this in v2.1.0 func Compare(a, b interface{}) (equal bool) { equal = false if strings.TrimSpace(fmt.Sprintf("%v", a)) == strings.TrimSpace(fmt.Sprintf("%v", b)) { @@ -147,16 +153,19 @@ func Compare(a, b interface{}) (equal bool) { } // CompareNot !Compare +// Deprecated: using pkg/, we will delete this in v2.1.0 func CompareNot(a, b interface{}) (equal bool) { return !Compare(a, b) } // NotNil the same as CompareNot +// Deprecated: using pkg/, we will delete this in v2.1.0 func NotNil(a interface{}) (isNil bool) { return CompareNot(a, nil) } // GetConfig get the Appconfig +// Deprecated: using pkg/, we will delete this in v2.1.0 func GetConfig(returnType, key string, defaultVal interface{}) (value interface{}, err error) { switch returnType { case "String": @@ -195,11 +204,13 @@ func GetConfig(returnType, key string, defaultVal interface{}) (value interface{ } // Str2html Convert string to template.HTML type. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Str2html(raw string) template.HTML { return template.HTML(raw) } // Htmlquote returns quoted html string. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Htmlquote(text string) string { //HTML编码为实体符号 /* @@ -219,6 +230,7 @@ func Htmlquote(text string) string { } // Htmlunquote returns unquoted html string. +// Deprecated: using pkg/, we will delete this in v2.1.0 func Htmlunquote(text string) string { //实体符号解释为HTML /* @@ -249,11 +261,13 @@ func Htmlunquote(text string) string { // /user/John%20Doe // // more detail http://beego.me/docs/mvc/controller/urlbuilding.md +// Deprecated: using pkg/, we will delete this in v2.1.0 func URLFor(endpoint string, values ...interface{}) string { return BeeApp.Handlers.URLFor(endpoint, values...) } // AssetsJs returns script tag with src string. +// Deprecated: using pkg/, we will delete this in v2.1.0 func AssetsJs(text string) template.HTML { text = "" @@ -262,6 +276,7 @@ func AssetsJs(text string) template.HTML { } // AssetsCSS returns stylesheet link tag with src string. +// Deprecated: using pkg/, we will delete this in v2.1.0 func AssetsCSS(text string) template.HTML { text = "" @@ -411,6 +426,7 @@ func parseFormToStruct(form url.Values, objT reflect.Type, objV reflect.Value) e } // ParseForm will parse form values to struct via tag. +// Deprecated: using pkg/, we will delete this in v2.1.0 func ParseForm(form url.Values, obj interface{}) error { objT := reflect.TypeOf(obj) objV := reflect.ValueOf(obj) @@ -442,6 +458,7 @@ var unKind = map[reflect.Kind]bool{ // RenderForm will render object to form html. // obj must be a struct pointer. +// Deprecated: using pkg/, we will delete this in v2.1.0 func RenderForm(obj interface{}) template.HTML { objT := reflect.TypeOf(obj) objV := reflect.ValueOf(obj) @@ -715,6 +732,7 @@ func ge(arg1, arg2 interface{}) (bool, error) { // // {{ map_get m "a" }} // return 1 // {{ map_get m 1 "c" }} // return 4 +// Deprecated: using pkg/, we will delete this in v2.1.0 func MapGet(arg1 interface{}, arg2 ...interface{}) (interface{}, error) { arg1Type := reflect.TypeOf(arg1) arg1Val := reflect.ValueOf(arg1) diff --git a/tree.go b/tree.go index 9e53003b..7fa3a7cb 100644 --- a/tree.go +++ b/tree.go @@ -31,6 +31,7 @@ var ( // fixRouter stores Fixed Router // wildcard stores params // leaves store the endpoint information +// Deprecated: using pkg/, we will delete this in v2.1.0 type Tree struct { //prefix set for static router prefix string @@ -43,12 +44,14 @@ type Tree struct { } // NewTree return a new Tree +// Deprecated: using pkg/, we will delete this in v2.1.0 func NewTree() *Tree { return &Tree{} } // AddTree will add tree to the exist Tree // prefix should has no params +// Deprecated: using pkg/, we will delete this in v2.1.0 func (t *Tree) AddTree(prefix string, tree *Tree) { t.addtree(splitPath(prefix), tree, nil, "") } @@ -200,6 +203,7 @@ func filterTreeWithPrefix(t *Tree, wildcards []string, reg string) { } // AddRouter call addseg function +// Deprecated: using pkg/, we will delete this in v2.1.0 func (t *Tree) AddRouter(pattern string, runObject interface{}) { t.addseg(splitPath(pattern), runObject, nil, "") } @@ -283,6 +287,7 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string, } // Match router to runObject & params +// Deprecated: using pkg/, we will delete this in v2.1.0 func (t *Tree) Match(pattern string, ctx *context.Context) (runObject interface{}) { if len(pattern) == 0 || pattern[0] != '/' { return nil