Merge pull request #4464 from jihoon-seo/210128-Update-beego-pkg-paths
Update beego pkg paths in codes, comments and READMEs
This commit is contained in:
commit
8806d2599e
2
adapter/cache/cache.go
vendored
2
adapter/cache/cache.go
vendored
@ -16,7 +16,7 @@
|
|||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("memory", `{"interval":60}`)
|
// bm, err := cache.NewCache("memory", `{"interval":60}`)
|
||||||
|
|||||||
4
adapter/cache/memcache/memcache.go
vendored
4
adapter/cache/memcache/memcache.go
vendored
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/cache/memcache"
|
// _ "github.com/beego/beego/v2/client/cache/memcache"
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||||
|
|||||||
4
adapter/cache/redis/redis.go
vendored
4
adapter/cache/redis/redis.go
vendored
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/cache/redis"
|
// _ "github.com/beego/beego/v2/client/cache/redis"
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
// Package config is used to parse config.
|
// Package config is used to parse config.
|
||||||
// Usage:
|
// Usage:
|
||||||
// import "github.com/beego/beego/v2/config"
|
// import "github.com/beego/beego/v2/core/config"
|
||||||
// Examples.
|
// Examples.
|
||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("ini", "config.conf")
|
// cnf, err := config.NewConfig("ini", "config.conf")
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/config/xml"
|
// _ "github.com/beego/beego/v2/core/config/xml"
|
||||||
// "github.com/beego/beego/v2/config"
|
// "github.com/beego/beego/v2/core/config"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/config/yaml"
|
// _ "github.com/beego/beego/v2/core/config/yaml"
|
||||||
// "github.com/beego/beego/v2/config"
|
// "github.com/beego/beego/v2/core/config"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package context provide the context utils
|
// Package context provide the context utils
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/context"
|
// import "github.com/beego/beego/v2/server/web/context"
|
||||||
//
|
//
|
||||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||||
//
|
//
|
||||||
|
|||||||
@ -37,4 +37,3 @@ func TestConvertParams(t *testing.T) {
|
|||||||
}, reflect.TypeOf(Demo), ctx)
|
}, reflect.TypeOf(Demo), ctx)
|
||||||
assert.Equal(t, int64(11), res[0].Int())
|
assert.Equal(t, int64(11), res[0].Int())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
// "net/http"
|
// "net/http"
|
||||||
// "os"
|
// "os"
|
||||||
//
|
//
|
||||||
// "github.com/beego/beego/v2/grace"
|
// "github.com/beego/beego/v2/server/web/grace"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func handler(w http.ResponseWriter, r *http.Request) {
|
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package httplib is used as http.Client
|
// Package httplib is used as http.Client
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/httplib"
|
// import "github.com/beego/beego/v2/client/httplib"
|
||||||
//
|
//
|
||||||
// b := httplib.Post("http://beego.me/")
|
// b := httplib.Post("http://beego.me/")
|
||||||
// b.Param("username","astaxie")
|
// b.Param("username","astaxie")
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Log levels to control the logging output.
|
// Log levels to control the logging output.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
const (
|
const (
|
||||||
LevelEmergency = webLog.LevelEmergency
|
LevelEmergency = webLog.LevelEmergency
|
||||||
LevelAlert = webLog.LevelAlert
|
LevelAlert = webLog.LevelAlert
|
||||||
@ -36,90 +36,90 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// BeeLogger references the used application logger.
|
// BeeLogger references the used application logger.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
var BeeLogger = logs.GetBeeLogger()
|
var BeeLogger = logs.GetBeeLogger()
|
||||||
|
|
||||||
// SetLevel sets the global log level used by the simple logger.
|
// SetLevel sets the global log level used by the simple logger.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func SetLevel(l int) {
|
func SetLevel(l int) {
|
||||||
logs.SetLevel(l)
|
logs.SetLevel(l)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLogFuncCall set the CallDepth, default is 3
|
// SetLogFuncCall set the CallDepth, default is 3
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func SetLogFuncCall(b bool) {
|
func SetLogFuncCall(b bool) {
|
||||||
logs.SetLogFuncCall(b)
|
logs.SetLogFuncCall(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLogger sets a new logger.
|
// SetLogger sets a new logger.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func SetLogger(adaptername string, config string) error {
|
func SetLogger(adaptername string, config string) error {
|
||||||
return logs.SetLogger(adaptername, config)
|
return logs.SetLogger(adaptername, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emergency logs a message at emergency level.
|
// Emergency logs a message at emergency level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Emergency(v ...interface{}) {
|
func Emergency(v ...interface{}) {
|
||||||
logs.Emergency(generateFmtStr(len(v)), v...)
|
logs.Emergency(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alert logs a message at alert level.
|
// Alert logs a message at alert level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Alert(v ...interface{}) {
|
func Alert(v ...interface{}) {
|
||||||
logs.Alert(generateFmtStr(len(v)), v...)
|
logs.Alert(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Critical logs a message at critical level.
|
// Critical logs a message at critical level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Critical(v ...interface{}) {
|
func Critical(v ...interface{}) {
|
||||||
logs.Critical(generateFmtStr(len(v)), v...)
|
logs.Critical(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error logs a message at error level.
|
// Error logs a message at error level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Error(v ...interface{}) {
|
func Error(v ...interface{}) {
|
||||||
logs.Error(generateFmtStr(len(v)), v...)
|
logs.Error(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning logs a message at warning level.
|
// Warning logs a message at warning level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Warning(v ...interface{}) {
|
func Warning(v ...interface{}) {
|
||||||
logs.Warning(generateFmtStr(len(v)), v...)
|
logs.Warning(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn compatibility alias for Warning()
|
// Warn compatibility alias for Warning()
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Warn(v ...interface{}) {
|
func Warn(v ...interface{}) {
|
||||||
logs.Warn(generateFmtStr(len(v)), v...)
|
logs.Warn(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notice logs a message at notice level.
|
// Notice logs a message at notice level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Notice(v ...interface{}) {
|
func Notice(v ...interface{}) {
|
||||||
logs.Notice(generateFmtStr(len(v)), v...)
|
logs.Notice(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Informational logs a message at info level.
|
// Informational logs a message at info level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Informational(v ...interface{}) {
|
func Informational(v ...interface{}) {
|
||||||
logs.Informational(generateFmtStr(len(v)), v...)
|
logs.Informational(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info compatibility alias for Warning()
|
// Info compatibility alias for Warning()
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Info(v ...interface{}) {
|
func Info(v ...interface{}) {
|
||||||
logs.Info(generateFmtStr(len(v)), v...)
|
logs.Info(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug logs a message at debug level.
|
// Debug logs a message at debug level.
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Debug(v ...interface{}) {
|
func Debug(v ...interface{}) {
|
||||||
logs.Debug(generateFmtStr(len(v)), v...)
|
logs.Debug(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trace logs a message at trace level.
|
// Trace logs a message at trace level.
|
||||||
// compatibility alias for Warning()
|
// compatibility alias for Warning()
|
||||||
// Deprecated: use github.com/beego/beego/v2/logs instead.
|
// Deprecated: use github.com/beego/beego/v2/core/logs instead.
|
||||||
func Trace(v ...interface{}) {
|
func Trace(v ...interface{}) {
|
||||||
logs.Trace(generateFmtStr(len(v)), v...)
|
logs.Trace(generateFmtStr(len(v)), v...)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package logs provide a general log interface
|
// Package logs provide a general log interface
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/logs"
|
// import "github.com/beego/beego/v2/core/logs"
|
||||||
//
|
//
|
||||||
// log := NewLogger(10000)
|
// log := NewLogger(10000)
|
||||||
// log.SetLogger("console", "")
|
// log.SetLogger("console", "")
|
||||||
|
|||||||
@ -25,6 +25,7 @@ type User struct {
|
|||||||
type Seller struct {
|
type Seller struct {
|
||||||
Id int
|
Id int
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterModelWithPrefix(t *testing.T) {
|
func TestRegisterModelWithPrefix(t *testing.T) {
|
||||||
RegisterModelWithPrefix("test", &User{}, &Seller{})
|
RegisterModelWithPrefix("test", &User{}, &Seller{})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "fmt"
|
// "fmt"
|
||||||
// "github.com/beego/beego/v2/orm"
|
// "github.com/beego/beego/v2/client/orm"
|
||||||
// _ "github.com/go-sql-driver/mysql" // import your used driver
|
// _ "github.com/go-sql-driver/mysql" // import your used driver
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
// Simple Usage:
|
// Simple Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/apiauth"
|
// "github.com/beego/beego/v2/server/web/filter/apiauth"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main(){
|
// func main(){
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
// Simple Usage:
|
// Simple Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/auth"
|
// "github.com/beego/beego/v2/server/web/filter/auth"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main(){
|
// func main(){
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
// Simple Usage:
|
// Simple Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/authz"
|
// "github.com/beego/beego/v2/server/web/filter/authz"
|
||||||
// "github.com/casbin/casbin"
|
// "github.com/casbin/casbin"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
// Usage
|
// Usage
|
||||||
// import (
|
// import (
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/cors"
|
// "github.com/beego/beego/v2/server/web/filter/cors"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main() {
|
// func main() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/couchbase"
|
// _ "github.com/beego/beego/v2/server/web/session/couchbase"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/memcache"
|
// _ "github.com/beego/beego/v2/server/web/session/memcache"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -28,8 +28,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/mysql"
|
// _ "github.com/beego/beego/v2/server/web/session/mysql"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -38,8 +38,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/postgresql"
|
// _ "github.com/beego/beego/v2/server/web/session/postgresql"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/redis"
|
// _ "github.com/beego/beego/v2/server/web/session/redis"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/redis_cluster"
|
// _ "github.com/beego/beego/v2/server/web/session/redis_cluster"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/redis_sentinel"
|
// _ "github.com/beego/beego/v2/server/web/session/redis_sentinel"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -7,8 +7,8 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2"
|
"github.com/beego/beego/v2"
|
||||||
"github.com/beego/beego/v2/cache"
|
"github.com/beego/beego/v2/client/cache"
|
||||||
"github.com/beego/beego/v2/utils/captcha"
|
"github.com/beego/beego/v2/server/web/captcha"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cpt *captcha.Captcha
|
var cpt *captcha.Captcha
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// "github.com/beego/beego/v2/utils/captcha"
|
// "github.com/beego/beego/v2/server/web/captcha"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// var cpt *captcha.Captcha
|
// var cpt *captcha.Captcha
|
||||||
|
|||||||
@ -8,7 +8,7 @@ In your beego.Controller:
|
|||||||
|
|
||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import "github.com/beego/beego/v2/utils/pagination"
|
import "github.com/beego/beego/v2/server/web/pagination"
|
||||||
|
|
||||||
type PostsController struct {
|
type PostsController struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package validation for validations
|
// Package validation for validations
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "github.com/beego/beego/v2/validation"
|
// "github.com/beego/beego/v2/core/validation"
|
||||||
// "log"
|
// "log"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
|
|||||||
4
client/cache/README.md
vendored
4
client/cache/README.md
vendored
@ -4,7 +4,7 @@ cache is a Go cache manager. It can use many cache adapters. The repo is inspire
|
|||||||
|
|
||||||
## How to install?
|
## How to install?
|
||||||
|
|
||||||
go get github.com/beego/beego/v2/cache
|
go get github.com/beego/beego/v2/client/cache
|
||||||
|
|
||||||
## What adapters are supported?
|
## What adapters are supported?
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ As of now this cache support memory, Memcache and Redis.
|
|||||||
First you must import it
|
First you must import it
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/cache"
|
"github.com/beego/beego/v2/client/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
Then init a Cache (example with memory adapter)
|
Then init a Cache (example with memory adapter)
|
||||||
|
|||||||
2
client/cache/cache.go
vendored
2
client/cache/cache.go
vendored
@ -16,7 +16,7 @@
|
|||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("memory", `{"interval":60}`)
|
// bm, err := cache.NewCache("memory", `{"interval":60}`)
|
||||||
|
|||||||
4
client/cache/memcache/memcache.go
vendored
4
client/cache/memcache/memcache.go
vendored
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/cache/memcache"
|
// _ "github.com/beego/beego/v2/client/cache/memcache"
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||||
|
|||||||
4
client/cache/redis/redis.go
vendored
4
client/cache/redis/redis.go
vendored
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/cache/redis"
|
// _ "github.com/beego/beego/v2/client/cache/redis"
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||||
|
|||||||
@ -8,7 +8,7 @@ httplib is an libs help you to curl remote url.
|
|||||||
|
|
||||||
you can use Get to crawl data.
|
you can use Get to crawl data.
|
||||||
|
|
||||||
import "github.com/beego/beego/v2/httplib"
|
import "github.com/beego/beego/v2/client/httplib"
|
||||||
|
|
||||||
str, err := httplib.Get("http://beego.me/").String()
|
str, err := httplib.Get("http://beego.me/").String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -95,4 +95,4 @@ httplib support mutil file upload, use `req.PostFile()`
|
|||||||
|
|
||||||
See godoc for further documentation and examples.
|
See godoc for further documentation and examples.
|
||||||
|
|
||||||
* [godoc.org/github.com/beego/beego/v2/httplib](https://godoc.org/github.com/beego/beego/v2/httplib)
|
* [godoc.org/github.com/beego/beego/v2/client/httplib](https://godoc.org/github.com/beego/beego/v2/client/httplib)
|
||||||
|
|||||||
@ -51,7 +51,6 @@ Sometimes you got JSON document and you want to make it as request body. So you
|
|||||||
If you do this, you got this code. Instead, you should call Header to set Content-type and call Body to set body data.
|
If you do this, you got this code. Instead, you should call Header to set Content-type and call Body to set body data.
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
||||||
// start with 5 --------------------------------------------------------------------------
|
// start with 5 --------------------------------------------------------------------------
|
||||||
|
|
||||||
var CreateFormFileFailed = berror.DefineCode(5001001, moduleName, "CreateFormFileFailed", `
|
var CreateFormFileFailed = berror.DefineCode(5001001, moduleName, "CreateFormFileFailed", `
|
||||||
@ -125,7 +124,3 @@ Make sure that:
|
|||||||
1. You pass valid structure pointer to the function;
|
1. You pass valid structure pointer to the function;
|
||||||
2. The body is valid YAML document
|
2. The body is valid YAML document
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestNewHttpResponseWithJsonBody(t *testing.T) {
|
func TestNewHttpResponseWithJsonBody(t *testing.T) {
|
||||||
// string
|
// string
|
||||||
resp := NewHttpResponseWithJsonBody("{}")
|
resp := NewHttpResponseWithJsonBody("{}")
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package httplib is used as http.Client
|
// Package httplib is used as http.Client
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/httplib"
|
// import "github.com/beego/beego/v2/client/httplib"
|
||||||
//
|
//
|
||||||
// b := httplib.Post("http://beego.me/")
|
// b := httplib.Post("http://beego.me/")
|
||||||
// b.Param("username","astaxie")
|
// b.Param("username","astaxie")
|
||||||
|
|||||||
@ -309,7 +309,6 @@ func TestFilterChainOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
req.AddFilters(func(next Filter) Filter {
|
req.AddFilters(func(next Filter) Filter {
|
||||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||||
return NewHttpResponseWithJsonBody("second"), nil
|
return NewHttpResponseWithJsonBody("second"), nil
|
||||||
@ -419,10 +418,10 @@ func TestBeegoHTTPRequest_Body(t *testing.T) {
|
|||||||
req.Body(13)
|
req.Body(13)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type user struct {
|
type user struct {
|
||||||
Name string `xml:"name"`
|
Name string `xml:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequest_XMLBody(t *testing.T) {
|
func TestBeegoHTTPRequest_XMLBody(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.me")
|
||||||
body := &user{
|
body := &user{
|
||||||
|
|||||||
@ -76,5 +76,3 @@ func NewMock(con RequestCondition, resp *http.Response, err error) *Mock {
|
|||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,6 @@ func (sc *SimpleCondition) matchBodyFields(ctx context.Context, req *httplib.Bee
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
|
|
||||||
err = json.Unmarshal(bytes, &m)
|
err = json.Unmarshal(bytes, &m)
|
||||||
|
|||||||
@ -27,7 +27,7 @@ more features please read the docs
|
|||||||
|
|
||||||
**Install:**
|
**Install:**
|
||||||
|
|
||||||
go get github.com/beego/beego/v2/orm
|
go get github.com/beego/beego/v2/client/orm
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beego/beego/v2/orm"
|
"github.com/beego/beego/v2/client/orm"
|
||||||
_ "github.com/go-sql-driver/mysql" // import your used driver
|
_ "github.com/go-sql-driver/mysql" // import your used driver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package order_clause
|
package order_clause
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/client/orm/clauses"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/client/orm/clauses"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Sort int8
|
type Sort int8
|
||||||
|
|||||||
@ -16,10 +16,11 @@ package orm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beego/beego/v2/client/orm/clauses"
|
|
||||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/client/orm/clauses"
|
||||||
|
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||||
)
|
)
|
||||||
|
|
||||||
// table info struct.
|
// table info struct.
|
||||||
|
|||||||
@ -24,7 +24,9 @@ import (
|
|||||||
|
|
||||||
"github.com/beego/beego/v2/client/orm"
|
"github.com/beego/beego/v2/client/orm"
|
||||||
)
|
)
|
||||||
|
|
||||||
const mockErrorMsg = "mock error"
|
const mockErrorMsg = "mock error"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
orm.RegisterModel(&User{})
|
orm.RegisterModel(&User{})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import (
|
|||||||
// DoNothingQueryM2Mer do nothing
|
// DoNothingQueryM2Mer do nothing
|
||||||
// use it to build mock orm.QueryM2Mer
|
// use it to build mock orm.QueryM2Mer
|
||||||
type DoNothingQueryM2Mer struct {
|
type DoNothingQueryM2Mer struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DoNothingQueryM2Mer) AddWithCtx(ctx context.Context, i ...interface{}) (int64, error) {
|
func (d *DoNothingQueryM2Mer) AddWithCtx(ctx context.Context, i ...interface{}) (int64, error) {
|
||||||
@ -88,5 +87,3 @@ func (q *QueryM2MerCondition) Match(ctx context.Context, inv *orm.Invocation) bo
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -58,11 +58,12 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/client/orm/hints"
|
"github.com/beego/beego/v2/client/orm/hints"
|
||||||
"github.com/beego/beego/v2/core/utils"
|
"github.com/beego/beego/v2/core/utils"
|
||||||
|
|
||||||
|
|||||||
@ -16,8 +16,9 @@ package orm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beego/beego/v2/client/orm/clauses"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/client/orm/clauses"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExprSep define the expression separation
|
// ExprSep define the expression separation
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
@ -32,6 +31,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/client/orm/hints"
|
"github.com/beego/beego/v2/client/orm/hints"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|||||||
@ -19,8 +19,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// A Code is an unsigned 32-bit error code as defined in the beego spec.
|
// A Code is an unsigned 32-bit error code as defined in the beego spec.
|
||||||
type Code interface {
|
type Code interface {
|
||||||
Code() uint32
|
Code() uint32
|
||||||
@ -57,7 +55,6 @@ type codeRegistry struct {
|
|||||||
codes map[uint32]*codeDefinition
|
codes map[uint32]*codeDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (cr *codeRegistry) Get(code uint32) (Code, bool) {
|
func (cr *codeRegistry) Get(code uint32) (Code, bool) {
|
||||||
cr.lock.RLock()
|
cr.lock.RLock()
|
||||||
defer cr.lock.RUnlock()
|
defer cr.lock.RUnlock()
|
||||||
@ -72,7 +69,6 @@ type codeDefinition struct {
|
|||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *codeDefinition) Name() string {
|
func (c *codeDefinition) Name() string {
|
||||||
return c.name
|
return c.name
|
||||||
}
|
}
|
||||||
@ -88,4 +84,3 @@ func (c *codeDefinition) Module() string {
|
|||||||
func (c *codeDefinition) Desc() string {
|
func (c *codeDefinition) Desc() string {
|
||||||
return c.desc
|
return c.desc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,4 +49,3 @@ func goCodeBlock(code string) string {
|
|||||||
func codeBlock(lan string, code string) string {
|
func codeBlock(lan string, code string) string {
|
||||||
return fmt.Sprintf("```%s\n%s\n```", lan, code)
|
return fmt.Sprintf("```%s\n%s\n```", lan, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
// Package config is used to parse config.
|
// Package config is used to parse config.
|
||||||
// Usage:
|
// Usage:
|
||||||
// import "github.com/beego/beego/v2/config"
|
// import "github.com/beego/beego/v2/core/config"
|
||||||
// Examples.
|
// Examples.
|
||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("ini", "config.conf")
|
// cnf, err := config.NewConfig("ini", "config.conf")
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/config/xml"
|
// _ "github.com/beego/beego/v2/core/config/xml"
|
||||||
// "github.com/beego/beego/v2/config"
|
// "github.com/beego/beego/v2/core/config"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/config/yaml"
|
// _ "github.com/beego/beego/v2/core/config/yaml"
|
||||||
// "github.com/beego/beego/v2/config"
|
// "github.com/beego/beego/v2/core/config"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||||
|
|||||||
@ -4,7 +4,7 @@ logs is a Go logs manager. It can use many logs adapters. The repo is inspired b
|
|||||||
|
|
||||||
## How to install?
|
## How to install?
|
||||||
|
|
||||||
go get github.com/beego/beego/v2/logs
|
go get github.com/beego/beego/v2/core/logs
|
||||||
|
|
||||||
## What adapters are supported?
|
## What adapters are supported?
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ First you must import it
|
|||||||
|
|
||||||
```golang
|
```golang
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/logs"
|
"github.com/beego/beego/v2/core/logs"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ func NewES() logs.Logger {
|
|||||||
// please import this package
|
// please import this package
|
||||||
// usually means that you can import this package in your main package
|
// usually means that you can import this package in your main package
|
||||||
// for example, anonymous:
|
// for example, anonymous:
|
||||||
// import _ "github.com/beego/beego/v2/logs/es"
|
// import _ "github.com/beego/beego/v2/core/logs/es"
|
||||||
type esLogger struct {
|
type esLogger struct {
|
||||||
*elasticsearch.Client
|
*elasticsearch.Client
|
||||||
DSN string `json:"dsn"`
|
DSN string `json:"dsn"`
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package logs provide a general log interface
|
// Package logs provide a general log interface
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/logs"
|
// import "github.com/beego/beego/v2/core/logs"
|
||||||
//
|
//
|
||||||
// log := NewLogger(10000)
|
// log := NewLogger(10000)
|
||||||
// log.SetLogger("console", "")
|
// log.SetLogger("console", "")
|
||||||
|
|||||||
@ -7,18 +7,18 @@ validation is a form validation for a data validation and error collecting using
|
|||||||
|
|
||||||
Install:
|
Install:
|
||||||
|
|
||||||
go get github.com/beego/beego/v2/validation
|
go get github.com/beego/beego/v2/core/validation
|
||||||
|
|
||||||
Test:
|
Test:
|
||||||
|
|
||||||
go test github.com/beego/beego/v2/validation
|
go test github.com/beego/beego/v2/core/validation
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Direct Use:
|
Direct Use:
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/validation"
|
"github.com/beego/beego/v2/core/validation"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ Direct Use:
|
|||||||
Struct Tag Use:
|
Struct Tag Use:
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/validation"
|
"github.com/beego/beego/v2/core/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// validation function follow with "valid" tag
|
// validation function follow with "valid" tag
|
||||||
@ -81,7 +81,7 @@ Struct Tag Use:
|
|||||||
Use custom function:
|
Use custom function:
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/validation"
|
"github.com/beego/beego/v2/core/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
type user struct {
|
type user struct {
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package validation for validations
|
// Package validation for validations
|
||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "github.com/beego/beego/v2/validation"
|
// "github.com/beego/beego/v2/core/validation"
|
||||||
// "log"
|
// "log"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
|
|||||||
@ -7,8 +7,8 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2"
|
"github.com/beego/beego/v2"
|
||||||
"github.com/beego/beego/v2/cache"
|
"github.com/beego/beego/v2/client/cache"
|
||||||
"github.com/beego/beego/v2/utils/captcha"
|
"github.com/beego/beego/v2/server/web/captcha"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cpt *captcha.Captcha
|
var cpt *captcha.Captcha
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// import (
|
// import (
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/cache"
|
// "github.com/beego/beego/v2/client/cache"
|
||||||
// "github.com/beego/beego/v2/utils/captcha"
|
// "github.com/beego/beego/v2/server/web/captcha"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// var cpt *captcha.Captcha
|
// var cpt *captcha.Captcha
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
// Package context provide the context utils
|
// Package context provide the context utils
|
||||||
// Usage:
|
// Usage:
|
||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/context"
|
// import "github.com/beego/beego/v2/server/web/context"
|
||||||
//
|
//
|
||||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||||
//
|
//
|
||||||
@ -29,13 +29,14 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/beego/beego/v2/server/web/session"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/server/web/session"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/core/utils"
|
"github.com/beego/beego/v2/core/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -15,10 +15,11 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/server/web/session"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/beego/beego/v2/server/web/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestXsrfReset_01(t *testing.T) {
|
func TestXsrfReset_01(t *testing.T) {
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
// Simple Usage:
|
// Simple Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/apiauth"
|
// "github.com/beego/beego/v2/server/web/filter/apiauth"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main(){
|
// func main(){
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
// Simple Usage:
|
// Simple Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/auth"
|
// "github.com/beego/beego/v2/server/web/filter/auth"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main(){
|
// func main(){
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
// Simple Usage:
|
// Simple Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/authz"
|
// "github.com/beego/beego/v2/server/web/filter/authz"
|
||||||
// "github.com/casbin/casbin"
|
// "github.com/casbin/casbin"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
// Usage
|
// Usage
|
||||||
// import (
|
// import (
|
||||||
// "github.com/beego/beego/v2"
|
// "github.com/beego/beego/v2"
|
||||||
// "github.com/beego/beego/v2/plugins/cors"
|
// "github.com/beego/beego/v2/server/web/filter/cors"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func main() {
|
// func main() {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package session
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/core/logs"
|
"github.com/beego/beego/v2/core/logs"
|
||||||
"github.com/beego/beego/v2/server/web"
|
"github.com/beego/beego/v2/server/web"
|
||||||
webContext "github.com/beego/beego/v2/server/web/context"
|
webContext "github.com/beego/beego/v2/server/web/context"
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/server/web"
|
"github.com/beego/beego/v2/server/web"
|
||||||
webContext "github.com/beego/beego/v2/server/web/context"
|
webContext "github.com/beego/beego/v2/server/web/context"
|
||||||
"github.com/beego/beego/v2/server/web/session"
|
"github.com/beego/beego/v2/server/web/session"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func testRequest(t *testing.T, handler *web.ControllerRegister, path string, method string, code int) {
|
func testRequest(t *testing.T, handler *web.ControllerRegister, path string, method string, code int) {
|
||||||
|
|||||||
@ -60,7 +60,6 @@ func TestControllerRegister_InsertFilterChain_Order(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
InsertFilterChain("/abc", func(next FilterFunc) FilterFunc {
|
InsertFilterChain("/abc", func(next FilterFunc) FilterFunc {
|
||||||
return func(ctx *context.Context) {
|
return func(ctx *context.Context) {
|
||||||
ctx.Output.Header("second", fmt.Sprintf("%d", time.Now().UnixNano()))
|
ctx.Output.Header("second", fmt.Sprintf("%d", time.Now().UnixNano()))
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
// "net/http"
|
// "net/http"
|
||||||
// "os"
|
// "os"
|
||||||
//
|
//
|
||||||
// "github.com/beego/beego/v2/grace"
|
// "github.com/beego/beego/v2/server/web/grace"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func handler(w http.ResponseWriter, r *http.Request) {
|
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ and `database/sql/driver`.
|
|||||||
|
|
||||||
## How to install?
|
## How to install?
|
||||||
|
|
||||||
go get github.com/beego/beego/v2/session
|
go get github.com/beego/beego/v2/server/web/session
|
||||||
|
|
||||||
## What providers are supported?
|
## What providers are supported?
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ As of now this session manager support memory, file, Redis and MySQL.
|
|||||||
First you must import it
|
First you must import it
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/beego/beego/v2/session"
|
"github.com/beego/beego/v2/server/web/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
Then in you web app init the global session manager
|
Then in you web app init the global session manager
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/couchbase"
|
// _ "github.com/beego/beego/v2/server/web/session/couchbase"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/memcache"
|
// _ "github.com/beego/beego/v2/server/web/session/memcache"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -28,8 +28,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/mysql"
|
// _ "github.com/beego/beego/v2/server/web/session/mysql"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -38,8 +38,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/postgresql"
|
// _ "github.com/beego/beego/v2/server/web/session/postgresql"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/redis"
|
// _ "github.com/beego/beego/v2/server/web/session/redis"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/redis_cluster"
|
// _ "github.com/beego/beego/v2/server/web/session/redis_cluster"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// _ "github.com/beego/beego/v2/session/redis_sentinel"
|
// _ "github.com/beego/beego/v2/server/web/session/redis_sentinel"
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// import(
|
// import(
|
||||||
// "github.com/beego/beego/v2/session"
|
// "github.com/beego/beego/v2/server/web/session"
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// func init() {
|
// func init() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user