Merge branch 'develop' into frt/delete-txorm
# Conflicts: # .travis.yml # CHANGELOG.md
This commit is contained in:
commit
8bd70bab96
23
.travis.yml
23
.travis.yml
@ -56,30 +56,9 @@ before_install:
|
||||
- docker exec etcd-gcr-v3.3.25 /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl put current.serialize.name test"
|
||||
- docker exec etcd-gcr-v3.3.25 /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl put sub.sub.key1 sub.sub.key"
|
||||
install:
|
||||
- go get github.com/lib/pq
|
||||
- go get github.com/go-sql-driver/mysql
|
||||
- go get github.com/mattn/go-sqlite3
|
||||
- go get github.com/bradfitz/gomemcache/memcache
|
||||
- go get github.com/gomodule/redigo/redis
|
||||
- go get github.com/beego/x2j
|
||||
- go get github.com/couchbase/go-couchbase
|
||||
- go get -u github.com/couchbase/gomemcached@master
|
||||
- go get github.com/beego/goyaml2
|
||||
- go get gopkg.in/yaml.v2
|
||||
- go get github.com/belogik/goes
|
||||
- go get github.com/ledisdb/ledisdb
|
||||
- go get github.com/ssdb/gossdb/ssdb
|
||||
- go get github.com/cloudflare/golz4
|
||||
- go get github.com/gogo/protobuf/proto
|
||||
- go get github.com/Knetic/govaluate
|
||||
- go get github.com/casbin/casbin
|
||||
- go get github.com/elazarl/go-bindata-assetfs
|
||||
- go get github.com/OwnLocal/goes
|
||||
- go get github.com/shiena/ansicolor
|
||||
- go get -u honnef.co/go/tools/cmd/staticcheck
|
||||
- go get -u github.com/mdempsky/unconvert
|
||||
- go get -u github.com/gordonklaus/ineffassign
|
||||
- go get -u github.com/go-redis/redis
|
||||
before_script:
|
||||
|
||||
# -
|
||||
@ -97,7 +76,7 @@ after_script:
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
script:
|
||||
- go test -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
- GO111MODULE=on go test -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
- staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-SA6005,-SA1019,-SA1024" ./
|
||||
- unconvert $(go list ./... | grep -v /vendor/)
|
||||
- ineffassign .
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
# developing
|
||||
- Fix: /abc.html/aaa match /abc/aaa. [4459](https://github.com/beego/beego/pull/4459)
|
||||
- ORM mock. [4407](https://github.com/beego/beego/pull/4407)
|
||||
- Add sonar check and ignore test. [4432](https://github.com/beego/beego/pull/4432) [4433](https://github.com/beego/beego/pull/4433)
|
||||
- Update changlog.yml to check every PR to develop branch.[4427](https://github.com/beego/beego/pull/4427)
|
||||
@ -16,4 +17,5 @@
|
||||
- Fix 4444: panic when 404 not found. [4446](https://github.com/beego/beego/pull/4446)
|
||||
- Fix 4435: fix panic when controller dir not found. [4452](https://github.com/beego/beego/pull/4452)
|
||||
- Fix 4456: Fix router method expression [4456](https://github.com/beego/beego/pull/4456)
|
||||
- Remove some `go get` lines in `.travis.yml` file [4469](https://github.com/beego/beego/pull/4469)
|
||||
- Fix 4451: support QueryExecutor interface. [4461](https://github.com/beego/beego/pull/4461)
|
||||
|
||||
@ -53,7 +53,7 @@ export SSDB_ADDR="192.168.0.105:8888"
|
||||
|
||||
### Pull requests
|
||||
|
||||
First of all. beego follow the gitflow. So please send you pull request to **develop-2** branch. We will close the pull
|
||||
First of all. beego follow the gitflow. So please send you pull request to **develop** branch. We will close the pull
|
||||
request to master branch.
|
||||
|
||||
We are always happy to receive pull requests, and do our best to review them as fast as possible. Not sure if that typo
|
||||
|
||||
2
adapter/cache/cache.go
vendored
2
adapter/cache/cache.go
vendored
@ -16,7 +16,7 @@
|
||||
// Usage:
|
||||
//
|
||||
// import(
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// 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:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/cache/memcache"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// _ "github.com/beego/beego/v2/client/cache/memcache"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// 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:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/cache/redis"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// _ "github.com/beego/beego/v2/client/cache/redis"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
// Package config is used to parse config.
|
||||
// Usage:
|
||||
// import "github.com/beego/beego/v2/config"
|
||||
// import "github.com/beego/beego/v2/core/config"
|
||||
// Examples.
|
||||
//
|
||||
// cnf, err := config.NewConfig("ini", "config.conf")
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/config/xml"
|
||||
// "github.com/beego/beego/v2/config"
|
||||
// _ "github.com/beego/beego/v2/core/config/xml"
|
||||
// "github.com/beego/beego/v2/core/config"
|
||||
// )
|
||||
//
|
||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/config/yaml"
|
||||
// "github.com/beego/beego/v2/config"
|
||||
// _ "github.com/beego/beego/v2/core/config/yaml"
|
||||
// "github.com/beego/beego/v2/core/config"
|
||||
// )
|
||||
//
|
||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package context provide the context utils
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/context"
|
||||
// import "github.com/beego/beego/v2/server/web/context"
|
||||
//
|
||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||
//
|
||||
|
||||
@ -37,4 +37,3 @@ func TestConvertParams(t *testing.T) {
|
||||
}, reflect.TypeOf(Demo), ctx)
|
||||
assert.Equal(t, int64(11), res[0].Int())
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
// "net/http"
|
||||
// "os"
|
||||
//
|
||||
// "github.com/beego/beego/v2/grace"
|
||||
// "github.com/beego/beego/v2/server/web/grace"
|
||||
// )
|
||||
//
|
||||
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package httplib is used as http.Client
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/httplib"
|
||||
// import "github.com/beego/beego/v2/client/httplib"
|
||||
//
|
||||
// b := httplib.Post("http://beego.me/")
|
||||
// b.Param("username","astaxie")
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
// 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 (
|
||||
LevelEmergency = webLog.LevelEmergency
|
||||
LevelAlert = webLog.LevelAlert
|
||||
@ -36,90 +36,90 @@ const (
|
||||
)
|
||||
|
||||
// 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()
|
||||
|
||||
// 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) {
|
||||
logs.SetLevel(l)
|
||||
}
|
||||
|
||||
// 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) {
|
||||
logs.SetLogFuncCall(b)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return logs.SetLogger(adaptername, config)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Emergency(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Alert(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Critical(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Error(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Warning(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Warn(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Notice(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Informational(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Info(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// 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{}) {
|
||||
logs.Debug(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
// Trace logs a message at trace level.
|
||||
// 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{}) {
|
||||
logs.Trace(generateFmtStr(len(v)), v...)
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package logs provide a general log interface
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/logs"
|
||||
// import "github.com/beego/beego/v2/core/logs"
|
||||
//
|
||||
// log := NewLogger(10000)
|
||||
// log.SetLogger("console", "")
|
||||
|
||||
@ -25,6 +25,7 @@ type User struct {
|
||||
type Seller struct {
|
||||
Id int
|
||||
}
|
||||
|
||||
func TestRegisterModelWithPrefix(t *testing.T) {
|
||||
RegisterModelWithPrefix("test", &User{}, &Seller{})
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
//
|
||||
// import (
|
||||
// "fmt"
|
||||
// "github.com/beego/beego/v2/orm"
|
||||
// "github.com/beego/beego/v2/client/orm"
|
||||
// _ "github.com/go-sql-driver/mysql" // import your used driver
|
||||
// )
|
||||
//
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
// Simple Usage:
|
||||
// import(
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/plugins/apiauth"
|
||||
// "github.com/beego/beego/v2/server/web/filter/apiauth"
|
||||
// )
|
||||
//
|
||||
// func main(){
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// Simple Usage:
|
||||
// import(
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/plugins/auth"
|
||||
// "github.com/beego/beego/v2/server/web/filter/auth"
|
||||
// )
|
||||
//
|
||||
// func main(){
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// Simple Usage:
|
||||
// import(
|
||||
// "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"
|
||||
// )
|
||||
//
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// Usage
|
||||
// import (
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/plugins/cors"
|
||||
// "github.com/beego/beego/v2/server/web/filter/cors"
|
||||
// )
|
||||
//
|
||||
// func main() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/couchbase"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/couchbase"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/memcache"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/memcache"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/mysql"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/mysql"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -38,8 +38,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/postgresql"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/postgresql"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/redis"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/redis"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/redis_cluster"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/redis_cluster"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/redis_sentinel"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/redis_sentinel"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -7,8 +7,8 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2"
|
||||
"github.com/beego/beego/v2/cache"
|
||||
"github.com/beego/beego/v2/utils/captcha"
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/beego/beego/v2/server/web/captcha"
|
||||
)
|
||||
|
||||
var cpt *captcha.Captcha
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// import (
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// "github.com/beego/beego/v2/utils/captcha"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// "github.com/beego/beego/v2/server/web/captcha"
|
||||
// )
|
||||
//
|
||||
// var cpt *captcha.Captcha
|
||||
|
||||
@ -8,7 +8,7 @@ In your beego.Controller:
|
||||
|
||||
package controllers
|
||||
|
||||
import "github.com/beego/beego/v2/utils/pagination"
|
||||
import "github.com/beego/beego/v2/server/web/pagination"
|
||||
|
||||
type PostsController struct {
|
||||
beego.Controller
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package validation for validations
|
||||
//
|
||||
// import (
|
||||
// "github.com/beego/beego/v2/validation"
|
||||
// "github.com/beego/beego/v2/core/validation"
|
||||
// "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?
|
||||
|
||||
go get github.com/beego/beego/v2/cache
|
||||
go get github.com/beego/beego/v2/client/cache
|
||||
|
||||
## What adapters are supported?
|
||||
|
||||
@ -15,7 +15,7 @@ As of now this cache support memory, Memcache and Redis.
|
||||
First you must import it
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/cache"
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
)
|
||||
|
||||
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:
|
||||
//
|
||||
// import(
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// bm, err := cache.NewCache("memory", `{"interval":60}`)
|
||||
|
||||
4
client/cache/calc_utils_test.go
vendored
4
client/cache/calc_utils_test.go
vendored
@ -19,7 +19,7 @@ func TestIncr(t *testing.T) {
|
||||
t.Errorf("incr failed, expect %v, but %v actually", updateVal, val)
|
||||
return
|
||||
}
|
||||
_, err = incr(int(1 << (strconv.IntSize - 1) - 1))
|
||||
_, err = incr(int(1<<(strconv.IntSize-1) - 1))
|
||||
if err == nil {
|
||||
t.Error("incr failed")
|
||||
return
|
||||
@ -73,7 +73,7 @@ func TestIncr(t *testing.T) {
|
||||
t.Errorf("incr failed, expect %v, but %v actually", updateVal, val)
|
||||
return
|
||||
}
|
||||
_, err = incr(uint(1 << (strconv.IntSize) - 1))
|
||||
_, err = incr(uint(1<<(strconv.IntSize) - 1))
|
||||
if err == nil {
|
||||
t.Error("incr failed")
|
||||
return
|
||||
|
||||
4
client/cache/memcache/memcache.go
vendored
4
client/cache/memcache/memcache.go
vendored
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/cache/memcache"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// _ "github.com/beego/beego/v2/client/cache/memcache"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// 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:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/cache/redis"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// _ "github.com/beego/beego/v2/client/cache/redis"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// )
|
||||
//
|
||||
// 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.
|
||||
|
||||
import "github.com/beego/beego/v2/httplib"
|
||||
import "github.com/beego/beego/v2/client/httplib"
|
||||
|
||||
str, err := httplib.Get("http://beego.me/").String()
|
||||
if err != nil {
|
||||
@ -95,4 +95,4 @@ httplib support mutil file upload, use `req.PostFile()`
|
||||
|
||||
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.
|
||||
`)
|
||||
|
||||
|
||||
// start with 5 --------------------------------------------------------------------------
|
||||
|
||||
var CreateFormFileFailed = berror.DefineCode(5001001, moduleName, "CreateFormFileFailed", `
|
||||
@ -125,7 +124,3 @@ Make sure that:
|
||||
1. You pass valid structure pointer to the function;
|
||||
2. The body is valid YAML document
|
||||
`)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
func TestNewHttpResponseWithJsonBody(t *testing.T) {
|
||||
// string
|
||||
resp := NewHttpResponseWithJsonBody("{}")
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package httplib is used as http.Client
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/httplib"
|
||||
// import "github.com/beego/beego/v2/client/httplib"
|
||||
//
|
||||
// b := httplib.Post("http://beego.me/")
|
||||
// b.Param("username","astaxie")
|
||||
|
||||
@ -309,7 +309,6 @@ func TestFilterChainOrder(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
req.AddFilters(func(next Filter) Filter {
|
||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||
return NewHttpResponseWithJsonBody("second"), nil
|
||||
@ -419,10 +418,10 @@ func TestBeegoHTTPRequest_Body(t *testing.T) {
|
||||
req.Body(13)
|
||||
}
|
||||
|
||||
|
||||
type user struct {
|
||||
Name string `xml:"name"`
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequest_XMLBody(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
body := &user{
|
||||
|
||||
@ -44,7 +44,7 @@ func StartMock() Stub {
|
||||
return mockFilter
|
||||
}
|
||||
|
||||
func CtxWithMock(ctx context.Context, mock... *Mock) context.Context {
|
||||
func CtxWithMock(ctx context.Context, mock ...*Mock) context.Context {
|
||||
return context.WithValue(ctx, mockCtxKey, mock)
|
||||
}
|
||||
|
||||
@ -76,5 +76,3 @@ func NewMock(con RequestCondition, resp *http.Response, err error) *Mock {
|
||||
err: err,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -120,7 +120,6 @@ func (sc *SimpleCondition) matchBodyFields(ctx context.Context, req *httplib.Bee
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
m := make(map[string]interface{})
|
||||
|
||||
err = json.Unmarshal(bytes, &m)
|
||||
|
||||
@ -72,6 +72,6 @@ func OriginnalCodeUsingHttplibPassCtx(ctx context.Context) (*http.Response, erro
|
||||
return httplib.Get("http://localhost:7777/abc").DoRequestWithCtx(ctx)
|
||||
}
|
||||
|
||||
func OriginalCodeUsingHttplib() (*http.Response, error){
|
||||
func OriginalCodeUsingHttplib() (*http.Response, error) {
|
||||
return httplib.Get("http://localhost:7777/abc").DoRequest()
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ more features please read the docs
|
||||
|
||||
**Install:**
|
||||
|
||||
go get github.com/beego/beego/v2/orm
|
||||
go get github.com/beego/beego/v2/client/orm
|
||||
|
||||
## Changelog
|
||||
|
||||
@ -45,7 +45,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/orm"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
_ "github.com/go-sql-driver/mysql" // import your used driver
|
||||
)
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package order_clause
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
)
|
||||
|
||||
type Sort int8
|
||||
|
||||
@ -16,10 +16,11 @@ package orm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
)
|
||||
|
||||
// table info struct.
|
||||
|
||||
@ -24,7 +24,9 @@ import (
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
)
|
||||
|
||||
const mockErrorMsg = "mock error"
|
||||
|
||||
func init() {
|
||||
orm.RegisterModel(&User{})
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import (
|
||||
// DoNothingQueryM2Mer do nothing
|
||||
// use it to build mock orm.QueryM2Mer
|
||||
type DoNothingQueryM2Mer struct {
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -58,11 +58,12 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
"os"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/hints"
|
||||
"github.com/beego/beego/v2/core/utils"
|
||||
|
||||
|
||||
@ -16,8 +16,9 @@ package orm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses"
|
||||
)
|
||||
|
||||
// ExprSep define the expression separation
|
||||
|
||||
@ -21,7 +21,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
@ -32,6 +31,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/clauses/order_clause"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm/hints"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@ -19,8 +19,6 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
||||
|
||||
// A Code is an unsigned 32-bit error code as defined in the beego spec.
|
||||
type Code interface {
|
||||
Code() uint32
|
||||
@ -57,7 +55,6 @@ type codeRegistry struct {
|
||||
codes map[uint32]*codeDefinition
|
||||
}
|
||||
|
||||
|
||||
func (cr *codeRegistry) Get(code uint32) (Code, bool) {
|
||||
cr.lock.RLock()
|
||||
defer cr.lock.RUnlock()
|
||||
@ -72,7 +69,6 @@ type codeDefinition struct {
|
||||
name string
|
||||
}
|
||||
|
||||
|
||||
func (c *codeDefinition) Name() string {
|
||||
return c.name
|
||||
}
|
||||
@ -88,4 +84,3 @@ func (c *codeDefinition) Module() string {
|
||||
func (c *codeDefinition) Desc() string {
|
||||
return c.desc
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
// pre define code
|
||||
|
||||
// Unknown indicates got some error which is not defined
|
||||
var Unknown = DefineCode(5000001, "error", "Unknown",fmt.Sprintf(`
|
||||
var Unknown = DefineCode(5000001, "error", "Unknown", fmt.Sprintf(`
|
||||
Unknown error code. Usually you will see this code in three cases:
|
||||
1. You forget to define Code or function DefineCode not being executed;
|
||||
2. This is not Beego's error but you call FromError();
|
||||
@ -49,4 +49,3 @@ func goCodeBlock(code string) string {
|
||||
func codeBlock(lan string, code string) string {
|
||||
return fmt.Sprintf("```%s\n%s\n```", lan, code)
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
// Package config is used to parse config.
|
||||
// Usage:
|
||||
// import "github.com/beego/beego/v2/config"
|
||||
// import "github.com/beego/beego/v2/core/config"
|
||||
// Examples.
|
||||
//
|
||||
// cnf, err := config.NewConfig("ini", "config.conf")
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/config/xml"
|
||||
// "github.com/beego/beego/v2/config"
|
||||
// _ "github.com/beego/beego/v2/core/config/xml"
|
||||
// "github.com/beego/beego/v2/core/config"
|
||||
// )
|
||||
//
|
||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/config/yaml"
|
||||
// "github.com/beego/beego/v2/config"
|
||||
// _ "github.com/beego/beego/v2/core/config/yaml"
|
||||
// "github.com/beego/beego/v2/core/config"
|
||||
// )
|
||||
//
|
||||
// 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?
|
||||
|
||||
go get github.com/beego/beego/v2/logs
|
||||
go get github.com/beego/beego/v2/core/logs
|
||||
|
||||
## What adapters are supported?
|
||||
|
||||
@ -16,7 +16,7 @@ First you must import it
|
||||
|
||||
```golang
|
||||
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
|
||||
// usually means that you can import this package in your main package
|
||||
// for example, anonymous:
|
||||
// import _ "github.com/beego/beego/v2/logs/es"
|
||||
// import _ "github.com/beego/beego/v2/core/logs/es"
|
||||
type esLogger struct {
|
||||
*elasticsearch.Client
|
||||
DSN string `json:"dsn"`
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package logs provide a general log interface
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/logs"
|
||||
// import "github.com/beego/beego/v2/core/logs"
|
||||
//
|
||||
// log := NewLogger(10000)
|
||||
// log.SetLogger("console", "")
|
||||
|
||||
@ -7,18 +7,18 @@ validation is a form validation for a data validation and error collecting using
|
||||
|
||||
Install:
|
||||
|
||||
go get github.com/beego/beego/v2/validation
|
||||
go get github.com/beego/beego/v2/core/validation
|
||||
|
||||
Test:
|
||||
|
||||
go test github.com/beego/beego/v2/validation
|
||||
go test github.com/beego/beego/v2/core/validation
|
||||
|
||||
## Example
|
||||
|
||||
Direct Use:
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
"log"
|
||||
)
|
||||
|
||||
@ -49,7 +49,7 @@ Direct Use:
|
||||
Struct Tag Use:
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
)
|
||||
|
||||
// validation function follow with "valid" tag
|
||||
@ -81,7 +81,7 @@ Struct Tag Use:
|
||||
Use custom function:
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/validation"
|
||||
"github.com/beego/beego/v2/core/validation"
|
||||
)
|
||||
|
||||
type user struct {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package validation for validations
|
||||
//
|
||||
// import (
|
||||
// "github.com/beego/beego/v2/validation"
|
||||
// "github.com/beego/beego/v2/core/validation"
|
||||
// "log"
|
||||
// )
|
||||
//
|
||||
|
||||
4
go.mod
4
go.mod
@ -12,8 +12,8 @@ require (
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
|
||||
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20201215185628-3bc3f73e68cb // indirect
|
||||
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836 // indirect
|
||||
github.com/couchbase/goutils v0.0.0-20201030094643-5e82bb967e67 // indirect
|
||||
github.com/elastic/go-elasticsearch/v6 v6.8.5
|
||||
github.com/elazarl/go-bindata-assetfs v1.0.0
|
||||
|
||||
4
go.sum
4
go.sum
@ -42,6 +42,8 @@ github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d h1:OMrhQqj1
|
||||
github.com/couchbase/go-couchbase v0.0.0-20200519150804-63f3cdb75e0d/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17 h1:1ZELwRDUvpBpmgKSIUP6VMW1jIehzD0sCdWxRyejegw=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20201216133707-c04035124b17/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef h1:pXh08kdOlR7eZbHWd7Zvz2KZbI2sxbHRxM+UTWj6oQ0=
|
||||
github.com/couchbase/go-couchbase v0.0.0-20210126152612-8e416c37c8ef/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A=
|
||||
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808 h1:8s2l8TVUwMXl6tZMe3+hPCRJ25nQXiA3d1x622JtOqc=
|
||||
github.com/couchbase/gomemcached v0.0.0-20200526233749-ec430f949808/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
|
||||
github.com/couchbase/gomemcached v0.1.0 h1:whUde87n8CScx8ckMp2En5liqAlcuG3aKy/BQeBPu84=
|
||||
@ -50,6 +52,8 @@ github.com/couchbase/gomemcached v0.1.1 h1:xCS8ZglJDhrlQg3jmK7Rn1V8f7bPjXABLC05C
|
||||
github.com/couchbase/gomemcached v0.1.1/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20201215185628-3bc3f73e68cb h1:ZCFku0K/3Xvl7rXkGGM+ioT76Rxko8V9wDEWa0GFp14=
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20201215185628-3bc3f73e68cb/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836 h1:ZxgtUfduO/Fk2NY1e1YhlgN6tRl0TMdXK9ElddO7uZY=
|
||||
github.com/couchbase/gomemcached v0.1.2-0.20210126151728-840240974836/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a h1:Y5XsLCEhtEI8qbD9RP3Qlv5FXdTDHxZM9UPUnMRgBp8=
|
||||
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
|
||||
github.com/couchbase/goutils v0.0.0-20201030094643-5e82bb967e67 h1:NCqJ6fwen6YP0WlV/IyibaT0kPt3JEI1rA62V/UPKT4=
|
||||
|
||||
@ -7,8 +7,8 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2"
|
||||
"github.com/beego/beego/v2/cache"
|
||||
"github.com/beego/beego/v2/utils/captcha"
|
||||
"github.com/beego/beego/v2/client/cache"
|
||||
"github.com/beego/beego/v2/server/web/captcha"
|
||||
)
|
||||
|
||||
var cpt *captcha.Captcha
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// import (
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/cache"
|
||||
// "github.com/beego/beego/v2/utils/captcha"
|
||||
// "github.com/beego/beego/v2/client/cache"
|
||||
// "github.com/beego/beego/v2/server/web/captcha"
|
||||
// )
|
||||
//
|
||||
// var cpt *captcha.Captcha
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
// Package context provide the context utils
|
||||
// Usage:
|
||||
//
|
||||
// import "github.com/beego/beego/v2/context"
|
||||
// import "github.com/beego/beego/v2/server/web/context"
|
||||
//
|
||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||
//
|
||||
@ -29,13 +29,14 @@ import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
|
||||
"github.com/beego/beego/v2/core/utils"
|
||||
)
|
||||
|
||||
|
||||
@ -15,10 +15,11 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
)
|
||||
|
||||
func TestXsrfReset_01(t *testing.T) {
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
// Simple Usage:
|
||||
// import(
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/plugins/apiauth"
|
||||
// "github.com/beego/beego/v2/server/web/filter/apiauth"
|
||||
// )
|
||||
//
|
||||
// func main(){
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// Simple Usage:
|
||||
// import(
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/plugins/auth"
|
||||
// "github.com/beego/beego/v2/server/web/filter/auth"
|
||||
// )
|
||||
//
|
||||
// func main(){
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// Simple Usage:
|
||||
// import(
|
||||
// "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"
|
||||
// )
|
||||
//
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
// Usage
|
||||
// import (
|
||||
// "github.com/beego/beego/v2"
|
||||
// "github.com/beego/beego/v2/plugins/cors"
|
||||
// "github.com/beego/beego/v2/server/web/filter/cors"
|
||||
// )
|
||||
//
|
||||
// func main() {
|
||||
|
||||
@ -2,6 +2,7 @@ package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
webContext "github.com/beego/beego/v2/server/web/context"
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/beego/beego/v2/server/web"
|
||||
webContext "github.com/beego/beego/v2/server/web/context"
|
||||
"github.com/beego/beego/v2/server/web/session"
|
||||
"github.com/google/uuid"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
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 {
|
||||
return func(ctx *context.Context) {
|
||||
ctx.Output.Header("second", fmt.Sprintf("%d", time.Now().UnixNano()))
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
// "net/http"
|
||||
// "os"
|
||||
//
|
||||
// "github.com/beego/beego/v2/grace"
|
||||
// "github.com/beego/beego/v2/server/web/grace"
|
||||
// )
|
||||
//
|
||||
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@ -6,7 +6,7 @@ and `database/sql/driver`.
|
||||
|
||||
## 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?
|
||||
|
||||
@ -17,7 +17,7 @@ As of now this session manager support memory, file, Redis and MySQL.
|
||||
First you must import it
|
||||
|
||||
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
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/couchbase"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/couchbase"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/memcache"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/memcache"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/mysql"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/mysql"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -38,8 +38,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/postgresql"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/postgresql"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/redis"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/redis"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/redis_cluster"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/redis_cluster"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// _ "github.com/beego/beego/v2/session/redis_sentinel"
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// _ "github.com/beego/beego/v2/server/web/session/redis_sentinel"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
//
|
||||
// Usage:
|
||||
// import(
|
||||
// "github.com/beego/beego/v2/session"
|
||||
// "github.com/beego/beego/v2/server/web/session"
|
||||
// )
|
||||
//
|
||||
// func init() {
|
||||
|
||||
@ -342,8 +342,9 @@ func (t *Tree) match(treePattern string, pattern string, wildcardValues []string
|
||||
if runObject == nil && len(t.fixrouters) > 0 {
|
||||
// Filter the .json .xml .html extension
|
||||
for _, str := range allowSuffixExt {
|
||||
if strings.HasSuffix(seg, str) {
|
||||
if strings.HasSuffix(seg, str) && strings.HasSuffix(treePattern, seg) {
|
||||
for _, subTree := range t.fixrouters {
|
||||
// strings.HasSuffix(treePattern, seg) avoid cases: /aaa.html/bbb could access /aaa/bbb
|
||||
if subTree.prefix == seg[:len(seg)-len(str)] {
|
||||
runObject = subTree.match(treePattern, pattern, wildcardValues, ctx)
|
||||
if runObject != nil {
|
||||
|
||||
@ -17,6 +17,7 @@ package web
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
)
|
||||
@ -49,7 +50,7 @@ func notMatchTestInfo(pattern, url string) testInfo {
|
||||
}
|
||||
|
||||
func init() {
|
||||
routers = make([]testInfo, 0)
|
||||
routers = make([]testInfo, 0, 128)
|
||||
// match example
|
||||
routers = append(routers, matchTestInfo("/topic/?:auth:int", "/topic", nil))
|
||||
routers = append(routers, matchTestInfo("/topic/?:auth:int", "/topic/123", map[string]string{":auth": "123"}))
|
||||
@ -108,12 +109,23 @@ func init() {
|
||||
routers = append(routers, notMatchTestInfo("/read_:id:int\\.htm", "/read_222_htm"))
|
||||
routers = append(routers, notMatchTestInfo("/read_:id:int\\.htm", " /read_262shtm"))
|
||||
|
||||
// test .html, .json not suffix
|
||||
const abcHtml = "/suffix/abc.html"
|
||||
routers = append(routers, notMatchTestInfo(abcHtml, "/suffix.html/abc"))
|
||||
routers = append(routers, matchTestInfo("/suffix/abc", abcHtml, nil))
|
||||
routers = append(routers, matchTestInfo("/suffix/*", abcHtml, nil))
|
||||
routers = append(routers, notMatchTestInfo("/suffix/*", "/suffix.html/a"))
|
||||
const abcSuffix = "/abc/suffix/*"
|
||||
routers = append(routers, notMatchTestInfo(abcSuffix, "/abc/suffix.html/a"))
|
||||
routers = append(routers, matchTestInfo(abcSuffix, "/abc/suffix/a", nil))
|
||||
routers = append(routers, notMatchTestInfo(abcSuffix, "/abc.j/suffix/a"))
|
||||
|
||||
}
|
||||
|
||||
func TestTreeRouters(t *testing.T) {
|
||||
for _, r := range routers {
|
||||
shouldMatch := r.shouldMatchOrNot
|
||||
|
||||
shouldMatch := r.shouldMatchOrNot
|
||||
tr := NewTree()
|
||||
tr.AddRouter(r.pattern, "astaxie")
|
||||
ctx := context.NewContext()
|
||||
@ -122,7 +134,7 @@ func TestTreeRouters(t *testing.T) {
|
||||
if obj != nil {
|
||||
t.Fatal("pattern:", r.pattern, ", should not match", r.requestUrl)
|
||||
} else {
|
||||
return
|
||||
continue
|
||||
}
|
||||
}
|
||||
if obj == nil || obj.(string) != "astaxie" {
|
||||
@ -138,6 +150,7 @@ func TestTreeRouters(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
func TestStaticPath(t *testing.T) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user