resolve conflict

This commit is contained in:
Ming Deng 2021-01-01 22:34:02 +08:00
commit 2ffb177868
307 changed files with 2467 additions and 1523 deletions

34
.github/workflows/changelog.yml vendored Normal file
View File

@ -0,0 +1,34 @@
# This action requires that any PR targeting the master branch should touch at
# least one CHANGELOG file. If a CHANGELOG entry is not required, add the "Skip
# Changelog" label to disable this action.
name: changelog
on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- master
jobs:
changelog:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.labels.*.name, 'Skip Changelog')"
steps:
- uses: actions/checkout@v2
- name: Check for CHANGELOG changes
run: |
# Only the latest commit of the feature branch is available
# automatically. To diff with the base branch, we need to
# fetch that too (and we only need its latest commit).
git fetch origin ${{ github.base_ref }} --depth=1
if [[ $(git diff --name-only FETCH_HEAD | grep CHANGELOG) ]]
then
echo "A CHANGELOG was modified. Looks good!"
else
echo "No CHANGELOG was modified."
echo "Please add a CHANGELOG entry, or add the \"Skip Changelog\" label if not required."
false
fi

2
.gitignore vendored
View File

@ -10,3 +10,5 @@ _beeTmp2/
pkg/_beeTmp/ pkg/_beeTmp/
pkg/_beeTmp2/ pkg/_beeTmp2/
test/tmp/ test/tmp/
profile.out

View File

@ -10,12 +10,13 @@ services:
- docker - docker
env: env:
global: global:
- GO_REPO_FULLNAME="github.com/astaxie/beego" - GO_REPO_FULLNAME="github.com/beego/beego/v2"
matrix: matrix:
- ORM_DRIVER=sqlite3 ORM_SOURCE=$TRAVIS_BUILD_DIR/orm_test.db - ORM_DRIVER=sqlite3 ORM_SOURCE=$TRAVIS_BUILD_DIR/orm_test.db
- ORM_DRIVER=postgres ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable" - ORM_DRIVER=postgres ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable"
- ORM_DRIVER=mysql export ORM_SOURCE="root:@/orm_test?charset=utf8" - ORM_DRIVER=mysql export ORM_SOURCE="root:@/orm_test?charset=utf8"
before_install: before_install:
- export CODECOV_TOKEN="4f4bc484-32a8-43b7-9f48-20966bd48ceb"
# link the local repo with ${GOPATH}/src/<namespace>/<repo> # link the local repo with ${GOPATH}/src/<namespace>/<repo>
- GO_REPO_NAMESPACE=${GO_REPO_FULLNAME%/*} - GO_REPO_NAMESPACE=${GO_REPO_FULLNAME%/*}
# relies on GOPATH to contain only one directory... # relies on GOPATH to contain only one directory...
@ -62,6 +63,7 @@ install:
- go get github.com/gomodule/redigo/redis - go get github.com/gomodule/redigo/redis
- go get github.com/beego/x2j - go get github.com/beego/x2j
- go get github.com/couchbase/go-couchbase - go get github.com/couchbase/go-couchbase
- go get -u github.com/couchbase/gomemcached@master
- go get github.com/beego/goyaml2 - go get github.com/beego/goyaml2
- go get gopkg.in/yaml.v2 - go get gopkg.in/yaml.v2
- go get github.com/belogik/goes - go get github.com/belogik/goes
@ -94,8 +96,10 @@ before_script:
after_script: after_script:
- killall -w ssdb-server - killall -w ssdb-server
- rm -rf ./res/var/* - rm -rf ./res/var/*
after_success:
- bash <(curl -s https://codecov.io/bash)
script: script:
- go test ./... - go test -coverprofile=coverage.txt -covermode=atomic ./...
- staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-SA6005,-SA1019,-SA1024" ./ - staticcheck -show-ignored -checks "-ST1017,-U1000,-ST1005,-S1034,-S1012,-SA4006,-SA6005,-SA1019,-SA1024" ./
- unconvert $(go list ./... | grep -v /vendor/) - unconvert $(go list ./... | grep -v /vendor/)
- ineffassign . - ineffassign .

6
CHANGELOG.md Normal file
View File

@ -0,0 +1,6 @@
# developing
- Fix 4396: Add context.param module into adapter. [4398](https://github.com/beego/beego/pull/4398)
- Remove `duration` from prometheus labels. [4391](https://github.com/beego/beego/pull/4391)
- Fix `unknown escape sequence` in generated code. [4385](https://github.com/beego/beego/pull/4385)
- Using fixed name `commentRouter.go` as generated file name. [4385](https://github.com/beego/beego/pull/4385)
- Fix 4383: ORM Adapter produces panic when using orm.RegisterModelWithPrefix. [4386](https://github.com/beego/beego/pull/4386)

View File

@ -4,8 +4,8 @@ beego is an open source project.
It is the work of hundreds of contributors. We appreciate your help! It is the work of hundreds of contributors. We appreciate your help!
Here are instructions to get you started. They are probably not perfect, Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or
please let us know if anything feels wrong or incomplete. incomplete.
## Prepare environment ## Prepare environment
@ -18,6 +18,7 @@ go get -u github.com/gordonklaus/ineffassign
``` ```
Put those lines into your pre-commit githook script: Put those lines into your pre-commit githook script:
```shell script ```shell script
goimports -w -format-only ./ goimports -w -format-only ./
@ -33,10 +34,13 @@ Beego uses many middlewares, including MySQL, Redis, SSDB and so on.
We provide docker compose file to start all middlewares. We provide docker compose file to start all middlewares.
You can run: You can run:
```shell script ```shell script
docker-compose -f scripts/test_docker_compose.yml up -d docker-compose -f scripts/test_docker_compose.yml up -d
``` ```
Unit tests read addresses from environment, here is an example: Unit tests read addresses from environment, here is an example:
```shell script ```shell script
export ORM_DRIVER=mysql export ORM_DRIVER=mysql
export ORM_SOURCE="beego:test@tcp(192.168.0.105:13306)/orm_test?charset=utf8" export ORM_SOURCE="beego:test@tcp(192.168.0.105:13306)/orm_test?charset=utf8"
@ -45,34 +49,28 @@ export REDIS_ADDR="192.168.0.105:6379"
export SSDB_ADDR="192.168.0.105:8888" export SSDB_ADDR="192.168.0.105:8888"
``` ```
## Contribution guidelines ## Contribution guidelines
### Pull requests ### Pull requests
First of all. beego follow the gitflow. So please send you pull request First of all. beego follow the gitflow. So please send you pull request to **develop-2** branch. We will close the pull
to **develop-2** branch. We will close the pull request to master branch. request to master branch.
We are always happy to receive pull requests, and do our best to We are always happy to receive pull requests, and do our best to review them as fast as possible. Not sure if that typo
review them as fast as possible. Not sure if that typo is worth a pull is worth a pull request? Do it! We will appreciate it.
request? Do it! We will appreciate it.
Don't forget to rebase your commits! Don't forget to rebase your commits!
If your pull request is not accepted on the first try, don't be If your pull request is not accepted on the first try, don't be discouraged! Sometimes we can make a mistake, please do
discouraged! Sometimes we can make a mistake, please do more explaining more explaining for us. We will appreciate it.
for us. We will appreciate it.
We're trying very hard to keep beego simple and fast. We don't want it We're trying very hard to keep beego simple and fast. We don't want it to do everything for everybody. This means that
to do everything for everybody. This means that we might decide against we might decide against incorporating a new feature. But we will give you some advice on how to do it in other way.
incorporating a new feature. But we will give you some advice on how to
do it in other way.
### Create issues ### Create issues
Any significant improvement should be documented as [a GitHub Any significant improvement should be documented as [a GitHub issue](https://github.com/beego/beego/v2/issues) before
issue](https://github.com/astaxie/beego/issues) before anybody anybody starts working on it.
starts working on it.
Also when filing an issue, make sure to answer these five questions: Also when filing an issue, make sure to answer these five questions:
@ -84,10 +82,8 @@ Also when filing an issue, make sure to answer these five questions:
### but check existing issues and docs first! ### but check existing issues and docs first!
Please take a moment to check that an issue doesn't already exist Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal.
documenting your bug report or improvement proposal. If it does, it If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common
never hurts to add a quick "+1" or "I have this problem too". This will problems and requests.
help prioritize the most common problems and requests.
Also, if you don't know how to use it. please make sure you have read through Also, if you don't know how to use it. please make sure you have read through the docs in http://beego.me/docs
the docs in http://beego.me/docs

260
README.md
View File

@ -1,19 +1,32 @@
# Beego [![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego) [![GoDoc](http://godoc.org/github.com/astaxie/beego?status.svg)](http://godoc.org/github.com/astaxie/beego) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org) [![Go Report Card](https://goreportcard.com/badge/github.com/astaxie/beego)](https://goreportcard.com/report/github.com/astaxie/beego) # Beego [![Build Status](https://travis-ci.org/astaxie/beego.svg?branch=master)](https://travis-ci.org/astaxie/beego) [![GoDoc](http://godoc.org/github.com/beego/beego/v2?status.svg)](http://godoc.org/github.com/beego/beego/v2) [![Foundation](https://img.shields.io/badge/Golang-Foundation-green.svg)](http://golangfoundation.org) [![Go Report Card](https://goreportcard.com/badge/github.com/beego/beego/v2)](https://goreportcard.com/report/github.com/beego/beego/v2)
Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend
services.
beego is used for rapid development of RESTful APIs, web apps and backend services in Go. It is inspired by Tornado, Sinatra and Flask. beego has some Go-specific features such as interfaces and struct
It is inspired by Tornado, Sinatra and Flask. beego has some Go-specific features such as interfaces and struct embedding. embedding.
###### More info at [beego.me](http://beego.me). ![architecture](https://cdn.nlark.com/yuque/0/2020/png/755700/1607857489109-1e267fce-d65f-4c5e-b915-5c475df33c58.png)
Beego is compos of four parts:
1. Base modules: including log module, config module, governor module;
2. Task: is used for running timed tasks or periodic tasks;
3. Client: including ORM module, httplib module, cache module;
4. Server: including web module. We will support gRPC in the future;
## Quick Start ## Quick Start
###### Please see [Documentation](http://beego.me/docs) for more. [Officail website](http://beego.me)
###### [beego-example](https://github.com/beego-dev/beego-example) [Example](https://github.com/beego/beego-example)
> If you could not open official website, go to [beedoc](https://github.com/beego/beedoc)
### Web Application ### Web Application
![Http Request](https://cdn.nlark.com/yuque/0/2020/png/755700/1607857462507-855ec543-7ce3-402d-a0cb-b2524d5a4b60.png)
#### Create `hello` directory, cd `hello` directory #### Create `hello` directory, cd `hello` directory
mkdir hello mkdir hello
@ -25,18 +38,20 @@ It is inspired by Tornado, Sinatra and Flask. beego has some Go-specific feature
#### Download and install #### Download and install
go get github.com/astaxie/beego go get github.com/beego/beego/v2@v2.0.0
#### Create file `hello.go` #### Create file `hello.go`
```go ```go
package main package main
import "github.com/astaxie/beego/server/web" import "github.com/beego/beego/v2/server/web"
func main(){ func main() {
web.Run() web.Run()
} }
``` ```
#### Build and run #### Build and run
go build hello.go go build hello.go
@ -46,227 +61,36 @@ func main(){
Congratulations! You've just built your first **beego** app. Congratulations! You've just built your first **beego** app.
### Using ORM module
```go
package main
import (
"github.com/astaxie/beego/client/orm"
"github.com/astaxie/beego/core/logs"
_ "github.com/go-sql-driver/mysql"
)
// User -
type User struct {
ID int `orm:"column(id)"`
Name string `orm:"column(name)"`
}
func init() {
// need to register models in init
orm.RegisterModel(new(User))
// need to register db driver
orm.RegisterDriver("mysql", orm.DRMySQL)
// need to register default database
orm.RegisterDataBase("default", "mysql", "beego:test@tcp(192.168.0.105:13306)/orm_test?charset=utf8")
}
func main() {
// automatically build table
orm.RunSyncdb("default", false, true)
// create orm object, and it will use `default` database
o := orm.NewOrm()
// data
user := new(User)
user.Name = "mike"
// insert data
id, err := o.Insert(user)
if err != nil {
logs.Info(err)
}
// ...
}
```
### Using httplib as http client
```go
package main
import (
"github.com/astaxie/beego/client/httplib"
"github.com/astaxie/beego/core/logs"
)
func main() {
// Get, more methods please read docs
req := httplib.Get("http://beego.me/")
str, err := req.String()
if err != nil {
logs.Error(err)
}
logs.Info(str)
}
```
### Using config module
```go
package main
import (
"context"
"github.com/astaxie/beego/core/config"
"github.com/astaxie/beego/core/logs"
)
var (
ConfigFile = "./app.conf"
)
func main() {
cfg, err := config.NewConfig("ini", ConfigFile)
if err != nil {
logs.Critical("An error occurred:", err)
panic(err)
}
res, _ := cfg.String(context.Background(), "name")
logs.Info("load config name is", res)
}
```
### Using logs module
```go
package main
import (
"github.com/astaxie/beego/core/logs"
)
func main() {
err := logs.SetLogger(logs.AdapterFile, `{"filename":"project.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10,"color":true}`)
if err != nil {
panic(err)
}
logs.Info("hello beego")
}
```
### Using timed task
```go
package main
import (
"context"
"time"
"github.com/astaxie/beego/core/logs"
"github.com/astaxie/beego/task"
)
func main() {
// create a task
tk1 := task.NewTask("tk1", "0/3 * * * * *", func(ctx context.Context) error { logs.Info("tk1"); return nil })
// check task
err := tk1.Run(context.Background())
if err != nil {
logs.Error(err)
}
// add task to global todolist
task.AddTask("tk1", tk1)
// start tasks
task.StartTask()
// wait 12 second
time.Sleep(12 * time.Second)
defer task.StopTask()
}
```
### Using cache module
```go
package main
import (
"context"
"time"
"github.com/astaxie/beego/client/cache"
// don't forget this
_ "github.com/astaxie/beego/client/cache/redis"
"github.com/astaxie/beego/core/logs"
)
func main() {
// create cache
bm, err := cache.NewCache("redis", `{"key":"default", "conn":":6379", "password":"123456", "dbNum":"0"}`)
if err != nil {
logs.Error(err)
}
// put
isPut := bm.Put(context.Background(), "astaxie", 1, time.Second*10)
logs.Info(isPut)
isPut = bm.Put(context.Background(), "hello", "world", time.Second*10)
logs.Info(isPut)
// get
result, _ := bm.Get(context.Background(),"astaxie")
logs.Info(string(result.([]byte)))
multiResult, _ := bm.GetMulti(context.Background(), []string{"astaxie", "hello"})
for i := range multiResult {
logs.Info(string(multiResult[i].([]byte)))
}
// isExist
isExist, _ := bm.IsExist(context.Background(), "astaxie")
logs.Info(isExist)
// delete
isDelete := bm.Delete(context.Background(), "astaxie")
logs.Info(isDelete)
}
```
## Features ## Features
* RESTful support * RESTful support
* MVC architecture * [MVC architecture](https://github.com/beego/beedoc/tree/master/en-US/mvc)
* Modularity * Modularity
* Auto API documents * [Auto API documents](https://github.com/beego/beedoc/blob/master/en-US/advantage/docs.md)
* Annotation router * [Annotation router](https://github.com/beego/beedoc/blob/master/en-US/mvc/controller/router.md)
* Namespace * [Namespace](https://github.com/beego/beedoc/blob/master/en-US/mvc/controller/router.md#namespace)
* Powerful development tools * [Powerful development tools](https://github.com/beego/bee)
* Full stack for Web & API * Full stack for Web & API
## Documentation ## Modules
* [English](http://beego.me/docs/intro/) * [orm](https://github.com/beego/beedoc/tree/master/en-US/mvc/model)
* [中文文档](http://beego.me/docs/intro/) * [session](https://github.com/beego/beedoc/blob/master/en-US/module/session.md)
* [Русский](http://beego.me/docs/intro/) * [logs](https://github.com/beego/beedoc/blob/master/en-US/module/logs.md)
* [config](https://github.com/beego/beedoc/blob/master/en-US/module/config.md)
* [cache](https://github.com/beego/beedoc/blob/master/en-US/module/cache.md)
* [context](https://github.com/beego/beedoc/blob/master/en-US/module/context.md)
* [admin](https://github.com/beego/beedoc/blob/master/en-US/module/admin.md)
* [httplib](https://github.com/beego/beedoc/blob/master/en-US/module/httplib.md)
* [task](https://github.com/beego/beedoc/blob/master/en-US/module/task.md)
* [i18n](https://github.com/beego/beedoc/blob/master/en-US/module/i18n.md)
## Community ## Community
* [http://beego.me/community](http://beego.me/community) * [http://beego.me/community](http://beego.me/community)
* Welcome to join us in Slack: [https://beego.slack.com](https://beego.slack.com), you can get invited from [here](https://github.com/beego/beedoc/issues/232) * Welcome to join us in Slack: [https://beego.slack.com invite](https://join.slack.com/t/beego/shared_invite/zt-fqlfjaxs-_CRmiITCSbEqQG9NeBqXKA),
* QQ Group Group ID:523992905 * QQ Group Group ID:523992905
* [Contribution Guide](https://github.com/beego/beedoc/blob/master/en-US/intro/contributing.md).
## License ## License

View File

@ -17,8 +17,8 @@ package adapter
import ( import (
"time" "time"
_ "github.com/astaxie/beego/core/governor" _ "github.com/beego/beego/v2/core/admin"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
// FilterMonitorFunc is default monitor filter when admin module is enable. // FilterMonitorFunc is default monitor filter when admin module is enable.

View File

@ -17,9 +17,9 @@ package adapter
import ( import (
"net/http" "net/http"
context2 "github.com/astaxie/beego/adapter/context" context2 "github.com/beego/beego/v2/adapter/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
) )
var ( var (

View File

@ -15,8 +15,8 @@
package adapter package adapter
import ( import (
"github.com/astaxie/beego" "github.com/beego/beego/v2"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
const ( const (

View File

@ -16,7 +16,7 @@
// Usage: // Usage:
// //
// import( // import(
// "github.com/astaxie/beego/cache" // "github.com/beego/beego/v2/cache"
// ) // )
// //
// bm, err := cache.NewCache("memory", `{"interval":60}`) // bm, err := cache.NewCache("memory", `{"interval":60}`)

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"time" "time"
"github.com/astaxie/beego/client/cache" "github.com/beego/beego/v2/client/cache"
) )
type newToOldCacheAdapter struct { type newToOldCacheAdapter struct {

View File

@ -26,7 +26,7 @@ func TestCacheIncr(t *testing.T) {
if err != nil { if err != nil {
t.Error("init err") t.Error("init err")
} }
//timeoutDuration := 10 * time.Second // timeoutDuration := 10 * time.Second
bm.Put("edwardhey", 0, time.Second*20) bm.Put("edwardhey", 0, time.Second*20)
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
@ -90,7 +90,7 @@ func TestCache(t *testing.T) {
t.Error("delete err") t.Error("delete err")
} }
//test GetMulti // test GetMulti
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil { if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }
@ -157,7 +157,7 @@ func TestFileCache(t *testing.T) {
t.Error("delete err") t.Error("delete err")
} }
//test string // test string
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil { if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }
@ -168,7 +168,7 @@ func TestFileCache(t *testing.T) {
t.Error("get err") t.Error("get err")
} }
//test GetMulti // test GetMulti
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil { if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }

View File

@ -15,7 +15,7 @@
package cache package cache
import ( import (
"github.com/astaxie/beego/client/cache" "github.com/beego/beego/v2/client/cache"
) )
// GetString convert interface to string. // GetString convert interface to string.

View File

@ -15,7 +15,7 @@
package cache package cache
import ( import (
"github.com/astaxie/beego/client/cache" "github.com/beego/beego/v2/client/cache"
) )
// NewFileCache Create new file cache with no config. // NewFileCache Create new file cache with no config.

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/cache/memcache" // _ "github.com/beego/beego/v2/cache/memcache"
// "github.com/astaxie/beego/cache" // "github.com/beego/beego/v2/cache"
// ) // )
// //
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`) // bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
@ -30,8 +30,8 @@
package memcache package memcache
import ( import (
"github.com/astaxie/beego/adapter/cache" "github.com/beego/beego/v2/adapter/cache"
"github.com/astaxie/beego/client/cache/memcache" "github.com/beego/beego/v2/client/cache/memcache"
) )
// NewMemCache create new memcache adapter. // NewMemCache create new memcache adapter.

View File

@ -21,7 +21,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/astaxie/beego/adapter/cache" "github.com/beego/beego/v2/adapter/cache"
) )
func TestMemcacheCache(t *testing.T) { func TestMemcacheCache(t *testing.T) {

View File

@ -15,7 +15,7 @@
package cache package cache
import ( import (
"github.com/astaxie/beego/client/cache" "github.com/beego/beego/v2/client/cache"
) )
// NewMemoryCache returns a new MemoryCache. // NewMemoryCache returns a new MemoryCache.

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/cache/redis" // _ "github.com/beego/beego/v2/cache/redis"
// "github.com/astaxie/beego/cache" // "github.com/beego/beego/v2/cache"
// ) // )
// //
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`) // bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
@ -30,8 +30,8 @@
package redis package redis
import ( import (
"github.com/astaxie/beego/adapter/cache" "github.com/beego/beego/v2/adapter/cache"
redis2 "github.com/astaxie/beego/client/cache/redis" redis2 "github.com/beego/beego/v2/client/cache/redis"
) )
var ( var (

View File

@ -22,7 +22,7 @@ import (
"github.com/gomodule/redigo/redis" "github.com/gomodule/redigo/redis"
"github.com/astaxie/beego/adapter/cache" "github.com/beego/beego/v2/adapter/cache"
) )
func TestRedisCache(t *testing.T) { func TestRedisCache(t *testing.T) {
@ -76,7 +76,7 @@ func TestRedisCache(t *testing.T) {
t.Error("delete err") t.Error("delete err")
} }
//test string // test string
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil { if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }
@ -88,7 +88,7 @@ func TestRedisCache(t *testing.T) {
t.Error("get err") t.Error("get err")
} }
//test GetMulti // test GetMulti
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil { if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }

View File

@ -1,8 +1,8 @@
package ssdb package ssdb
import ( import (
"github.com/astaxie/beego/adapter/cache" "github.com/beego/beego/v2/adapter/cache"
ssdb2 "github.com/astaxie/beego/client/cache/ssdb" ssdb2 "github.com/beego/beego/v2/client/cache/ssdb"
) )
// NewSsdbCache create new ssdb adapter. // NewSsdbCache create new ssdb adapter.

View File

@ -7,7 +7,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/astaxie/beego/adapter/cache" "github.com/beego/beego/v2/adapter/cache"
) )
func TestSsdbcacheCache(t *testing.T) { func TestSsdbcacheCache(t *testing.T) {
@ -26,7 +26,7 @@ func TestSsdbcacheCache(t *testing.T) {
t.Error("check err") t.Error("check err")
} }
timeoutDuration := 10 * time.Second timeoutDuration := 10 * time.Second
//timeoutDuration := -10*time.Second if timeoutDuration is negtive,it means permanent // timeoutDuration := -10*time.Second if timeoutDuration is negtive,it means permanent
if err = ssdb.Put("ssdb", "ssdb", timeoutDuration); err != nil { if err = ssdb.Put("ssdb", "ssdb", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }
@ -43,7 +43,7 @@ func TestSsdbcacheCache(t *testing.T) {
t.Error("get Error") t.Error("get Error")
} }
//inc/dec test done // inc/dec test done
if err = ssdb.Put("ssdb", "2", timeoutDuration); err != nil { if err = ssdb.Put("ssdb", "2", timeoutDuration); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }
@ -72,7 +72,7 @@ func TestSsdbcacheCache(t *testing.T) {
} }
} }
//test string // test string
if err = ssdb.Put("ssdb", "ssdb", -10*time.Second); err != nil { if err = ssdb.Put("ssdb", "ssdb", -10*time.Second); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }
@ -83,7 +83,7 @@ func TestSsdbcacheCache(t *testing.T) {
t.Error("get err") t.Error("get err")
} }
//test GetMulti done // test GetMulti done
if err = ssdb.Put("ssdb1", "ssdb1", -10*time.Second); err != nil { if err = ssdb.Put("ssdb1", "ssdb1", -10*time.Second); err != nil {
t.Error("set Error", err) t.Error("set Error", err)
} }

View File

@ -15,9 +15,9 @@
package adapter package adapter
import ( import (
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
newCfg "github.com/astaxie/beego/core/config" newCfg "github.com/beego/beego/v2/core/config"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
// Config is the main struct for BConfig // Config is the main struct for BConfig

View File

@ -17,7 +17,7 @@ package config
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/astaxie/beego/core/config" "github.com/beego/beego/v2/core/config"
) )
type newToOldConfigerAdapter struct { type newToOldConfigerAdapter struct {

View File

@ -14,7 +14,7 @@
// Package config is used to parse config. // Package config is used to parse config.
// Usage: // Usage:
// import "github.com/astaxie/beego/config" // import "github.com/beego/beego/v2/config"
// Examples. // Examples.
// //
// cnf, err := config.NewConfig("ini", "config.conf") // cnf, err := config.NewConfig("ini", "config.conf")
@ -41,7 +41,7 @@
package config package config
import ( import (
"github.com/astaxie/beego/core/config" "github.com/beego/beego/v2/core/config"
) )
// Configer defines how to get and set value from configuration raw data. // Configer defines how to get and set value from configuration raw data.

View File

@ -17,7 +17,7 @@
package env package env
import ( import (
"github.com/astaxie/beego/core/config/env" "github.com/beego/beego/v2/core/config/env"
) )
// Get returns a value by key. // Get returns a value by key.

View File

@ -15,7 +15,7 @@
package config package config
import ( import (
"github.com/astaxie/beego/core/config" "github.com/beego/beego/v2/core/config"
) )
// NewFakeConfig return a fake Configer // NewFakeConfig return a fake Configer

View File

@ -145,7 +145,7 @@ httpport = 8080
# enable db # enable db
[dbinfo] [dbinfo]
# db type name # db type name
# suport mysql,sqlserver # support mysql,sqlserver
name = mysql name = mysql
` `
@ -161,7 +161,7 @@ httpport=8080
# enable db # enable db
[dbinfo] [dbinfo]
# db type name # db type name
# suport mysql,sqlserver # support mysql,sqlserver
name=mysql name=mysql
` `
) )

View File

@ -15,5 +15,5 @@
package config package config
import ( import (
_ "github.com/astaxie/beego/core/config/json" _ "github.com/beego/beego/v2/core/config/json"
) )

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/config/xml" // _ "github.com/beego/beego/v2/config/xml"
// "github.com/astaxie/beego/config" // "github.com/beego/beego/v2/config"
// ) // )
// //
// cnf, err := config.NewConfig("xml", "config.xml") // cnf, err := config.NewConfig("xml", "config.xml")
@ -30,5 +30,5 @@
package xml package xml
import ( import (
_ "github.com/astaxie/beego/core/config/xml" _ "github.com/beego/beego/v2/core/config/xml"
) )

View File

@ -19,13 +19,13 @@ import (
"os" "os"
"testing" "testing"
"github.com/astaxie/beego/adapter/config" "github.com/beego/beego/v2/adapter/config"
) )
func TestXML(t *testing.T) { func TestXML(t *testing.T) {
var ( var (
//xml parse should incluce in <config></config> tags // xml parse should incluce in <config></config> tags
xmlcontext = `<?xml version="1.0" encoding="UTF-8"?> xmlcontext = `<?xml version="1.0" encoding="UTF-8"?>
<config> <config>
<appname>beeapi</appname> <appname>beeapi</appname>

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/config/yaml" // _ "github.com/beego/beego/v2/config/yaml"
// "github.com/astaxie/beego/config" // "github.com/beego/beego/v2/config"
// ) // )
// //
// cnf, err := config.NewConfig("yaml", "config.yaml") // cnf, err := config.NewConfig("yaml", "config.yaml")
@ -30,5 +30,5 @@
package yaml package yaml
import ( import (
_ "github.com/astaxie/beego/core/config/yaml" _ "github.com/beego/beego/v2/core/config/yaml"
) )

View File

@ -19,7 +19,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/astaxie/beego/adapter/config" "github.com/beego/beego/v2/adapter/config"
) )
func TestYaml(t *testing.T) { func TestYaml(t *testing.T) {

View File

@ -19,7 +19,7 @@ import (
"net/http" "net/http"
"os" "os"
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
) )
// InitGzip init the gzipcompress // InitGzip init the gzipcompress

View File

@ -15,7 +15,7 @@
// Package context provide the context utils // Package context provide the context utils
// Usage: // Usage:
// //
// import "github.com/astaxie/beego/context" // import "github.com/beego/beego/v2/context"
// //
// ctx := context.Context{Request:req,ResponseWriter:rw} // ctx := context.Context{Request:req,ResponseWriter:rw}
// //
@ -27,7 +27,7 @@ import (
"net" "net"
"net/http" "net/http"
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
) )
// commonly used mime-types // commonly used mime-types

View File

@ -15,7 +15,7 @@
package context package context
import ( import (
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
) )
// BeegoInput operates the http request header, data, cookie and body. // BeegoInput operates the http request header, data, cookie and body.

View File

@ -15,7 +15,7 @@
package context package context
import ( import (
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
) )
// BeegoOutput does work for sending response header. // BeegoOutput does work for sending response header.

View File

@ -0,0 +1,18 @@
package param
import (
"reflect"
beecontext "github.com/beego/beego/v2/adapter/context"
"github.com/beego/beego/v2/server/web/context"
"github.com/beego/beego/v2/server/web/context/param"
)
// ConvertParams converts http method params to values that will be passed to the method controller as arguments
func ConvertParams(methodParams []*MethodParam, methodType reflect.Type, ctx *beecontext.Context) (result []reflect.Value) {
nps := make([]*param.MethodParam, 0, len(methodParams))
for _, mp := range methodParams {
nps = append(nps, (*param.MethodParam)(mp))
}
return param.ConvertParams(nps, methodType, (*context.Context)(ctx))
}

View File

@ -0,0 +1,40 @@
// Copyright 2020 beego
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package param
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
"github.com/beego/beego/v2/adapter/context"
)
func Demo(i int) {
}
func TestConvertParams(t *testing.T) {
res := ConvertParams(nil, reflect.TypeOf(Demo), context.NewContext())
assert.Equal(t, 0, len(res))
ctx := context.NewContext()
ctx.Input.RequestBody = []byte("11")
res = ConvertParams([]*MethodParam{
New("A", InBody),
}, reflect.TypeOf(Demo), ctx)
assert.Equal(t, int64(11), res[0].Int())
}

View File

@ -0,0 +1,29 @@
package param
import (
"github.com/beego/beego/v2/server/web/context/param"
)
// MethodParam keeps param information to be auto passed to controller methods
type MethodParam param.MethodParam
// New creates a new MethodParam with name and specific options
func New(name string, opts ...MethodParamOption) *MethodParam {
newOps := make([]param.MethodParamOption, 0, len(opts))
for _, o := range opts {
newOps = append(newOps, oldMpoToNew(o))
}
return (*MethodParam)(param.New(name, newOps...))
}
// Make creates an array of MethodParmas or an empty array
func Make(list ...*MethodParam) []*MethodParam {
if len(list) > 0 {
return list
}
return nil
}
func (mp *MethodParam) String() string {
return (*param.MethodParam)(mp).String()
}

View File

@ -0,0 +1,34 @@
// Copyright 2020 beego
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package param
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMethodParam_String(t *testing.T) {
method := New("myName", IsRequired, InHeader, Default("abc"))
s := method.String()
assert.Equal(t, `param.New("myName", param.IsRequired, param.InHeader, param.Default("abc"))`, s)
}
func TestMake(t *testing.T) {
res := Make()
assert.Equal(t, 0, len(res))
res = Make(New("myName", InBody))
assert.Equal(t, 1, len(res))
}

View File

@ -0,0 +1,45 @@
package param
import (
"github.com/beego/beego/v2/server/web/context/param"
)
// MethodParamOption defines a func which apply options on a MethodParam
type MethodParamOption func(*MethodParam)
// IsRequired indicates that this param is required and can not be omitted from the http request
var IsRequired MethodParamOption = func(p *MethodParam) {
param.IsRequired((*param.MethodParam)(p))
}
// InHeader indicates that this param is passed via an http header
var InHeader MethodParamOption = func(p *MethodParam) {
param.InHeader((*param.MethodParam)(p))
}
// InPath indicates that this param is part of the URL path
var InPath MethodParamOption = func(p *MethodParam) {
param.InPath((*param.MethodParam)(p))
}
// InBody indicates that this param is passed as an http request body
var InBody MethodParamOption = func(p *MethodParam) {
param.InBody((*param.MethodParam)(p))
}
// Default provides a default value for the http param
func Default(defaultValue interface{}) MethodParamOption {
return newMpoToOld(param.Default(defaultValue))
}
func newMpoToOld(n param.MethodParamOption) MethodParamOption {
return func(methodParam *MethodParam) {
n((*param.MethodParam)(methodParam))
}
}
func oldMpoToNew(old MethodParamOption) param.MethodParamOption {
return func(methodParam *param.MethodParam) {
old((*MethodParam)(methodParam))
}
}

View File

@ -1,7 +1,7 @@
package context package context
import ( import (
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
) )
// Renderer defines an http response renderer // Renderer defines an http response renderer

View File

@ -18,10 +18,10 @@ import (
"mime/multipart" "mime/multipart"
"net/url" "net/url"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
webContext "github.com/astaxie/beego/server/web/context" webContext "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
var ( var (
@ -212,7 +212,8 @@ func (c *Controller) ServeFormatted(encoding ...bool) {
// Input returns the input data map from POST or PUT request body and query string. // Input returns the input data map from POST or PUT request body and query string.
func (c *Controller) Input() url.Values { func (c *Controller) Input() url.Values {
return (*web.Controller)(c).Input() val, _ := (*web.Controller)(c).Input()
return val
} }
// ParseForm maps input data map to obj struct. // ParseForm maps input data map to obj struct.

View File

@ -17,10 +17,10 @@ package adapter
import ( import (
"net/http" "net/http"
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
const ( const (

View File

@ -15,9 +15,9 @@
package adapter package adapter
import ( import (
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
) )
// FilterFunc defines a filter function which is invoked before the controller handler is executed. // FilterFunc defines a filter function which is invoked before the controller handler is executed.

View File

@ -15,7 +15,7 @@
package adapter package adapter
import ( import (
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
// FlashData is a tools to maintain data when using across request. // FlashData is a tools to maintain data when using across request.

View File

@ -18,7 +18,7 @@ import (
"net/http" "net/http"
"path/filepath" "path/filepath"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
type FileSystem web.FileSystem type FileSystem web.FileSystem

View File

@ -22,7 +22,7 @@
// "net/http" // "net/http"
// "os" // "os"
// //
// "github.com/astaxie/beego/grace" // "github.com/beego/beego/v2/grace"
// ) // )
// //
// func handler(w http.ResponseWriter, r *http.Request) { // func handler(w http.ResponseWriter, r *http.Request) {
@ -46,7 +46,7 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/astaxie/beego/server/web/grace" "github.com/beego/beego/v2/server/web/grace"
) )
const ( const (

View File

@ -3,7 +3,7 @@ package grace
import ( import (
"os" "os"
"github.com/astaxie/beego/server/web/grace" "github.com/beego/beego/v2/server/web/grace"
) )
// Server embedded http.Server // Server embedded http.Server

View File

@ -15,7 +15,7 @@
// Package httplib is used as http.Client // Package httplib is used as http.Client
// Usage: // Usage:
// //
// import "github.com/astaxie/beego/httplib" // import "github.com/beego/beego/v2/httplib"
// //
// b := httplib.Post("http://beego.me/") // b := httplib.Post("http://beego.me/")
// b.Param("username","astaxie") // b.Param("username","astaxie")
@ -38,7 +38,7 @@ import (
"net/url" "net/url"
"time" "time"
"github.com/astaxie/beego/client/httplib" "github.com/beego/beego/v2/client/httplib"
) )
// SetDefaultSetting Overwrite default settings // SetDefaultSetting Overwrite default settings

View File

@ -17,13 +17,13 @@ package adapter
import ( import (
"strings" "strings"
"github.com/astaxie/beego/core/logs" "github.com/beego/beego/v2/core/logs"
webLog "github.com/astaxie/beego/core/logs" webLog "github.com/beego/beego/v2/core/logs"
) )
// Log levels to control the logging output. // Log levels to control the logging output.
// Deprecated: use github.com/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/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/astaxie/beego/logs instead. // Deprecated: use github.com/beego/beego/v2/logs instead.
func Trace(v ...interface{}) { func Trace(v ...interface{}) {
logs.Trace(generateFmtStr(len(v)), v...) logs.Trace(generateFmtStr(len(v)), v...)
} }

View File

@ -15,7 +15,7 @@
package logs package logs
import ( import (
"github.com/astaxie/beego/core/logs" "github.com/beego/beego/v2/core/logs"
) )
// AccessLogRecord struct for holding access log data. // AccessLogRecord struct for holding access log data.

View File

@ -1,5 +1,5 @@
package alils package alils
import ( import (
_ "github.com/astaxie/beego/core/logs/alils" _ "github.com/beego/beego/v2/core/logs/alils"
) )

View File

@ -1,5 +1,5 @@
package es package es
import ( import (
_ "github.com/astaxie/beego/core/logs/es" _ "github.com/beego/beego/v2/core/logs/es"
) )

View File

@ -15,7 +15,7 @@
// Package logs provide a general log interface // Package logs provide a general log interface
// Usage: // Usage:
// //
// import "github.com/astaxie/beego/logs" // import "github.com/beego/beego/v2/logs"
// //
// log := NewLogger(10000) // log := NewLogger(10000)
// log.SetLogger("console", "") // log.SetLogger("console", "")
@ -37,7 +37,7 @@ import (
"log" "log"
"time" "time"
"github.com/astaxie/beego/core/logs" "github.com/beego/beego/v2/core/logs"
) )
// RFC5424 log message levels. // RFC5424 log message levels.

View File

@ -17,7 +17,7 @@ package logs
import ( import (
"time" "time"
"github.com/astaxie/beego/core/logs" "github.com/beego/beego/v2/core/logs"
) )
type oldToNewAdapter struct { type oldToNewAdapter struct {

View File

@ -15,7 +15,7 @@
package logs package logs
import ( import (
"github.com/astaxie/beego/core/logs" "github.com/beego/beego/v2/core/logs"
) )
// ColorByStatus return color by http code // ColorByStatus return color by http code

View File

@ -23,9 +23,9 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego" "github.com/beego/beego/v2"
"github.com/astaxie/beego/core/logs" "github.com/beego/beego/v2/core/logs"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
func PrometheusMiddleWare(next http.Handler) http.Handler { func PrometheusMiddleWare(next http.Handler) http.Handler {
@ -38,7 +38,7 @@ func PrometheusMiddleWare(next http.Handler) http.Handler {
"appname": web.BConfig.AppName, "appname": web.BConfig.AppName,
}, },
Help: "The statics info for http request", Help: "The statics info for http request",
}, []string{"pattern", "method", "status", "duration"}) }, []string{"pattern", "method", "status"})
prometheus.MustRegister(summaryVec) prometheus.MustRegister(summaryVec)
@ -96,5 +96,5 @@ func report(dur time.Duration, writer http.ResponseWriter, q *http.Request, vec
logs.Warn("we can not find the router info for this request, so request will be recorded as UNKNOWN: " + q.URL.String()) logs.Warn("we can not find the router info for this request, so request will be recorded as UNKNOWN: " + q.URL.String())
} }
ms := dur / time.Millisecond ms := dur / time.Millisecond
vec.WithLabelValues(ptn, q.Method, strconv.Itoa(status), strconv.Itoa(int(ms))).Observe(float64(ms)) vec.WithLabelValues(ptn, q.Method, strconv.Itoa(status)).Observe(float64(ms))
} }

View File

@ -22,7 +22,7 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
) )
func TestPrometheusMiddleWare(t *testing.T) { func TestPrometheusMiddleWare(t *testing.T) {
@ -35,7 +35,7 @@ func TestPrometheusMiddleWare(t *testing.T) {
}, },
Method: "POST", Method: "POST",
} }
vec := prometheus.NewSummaryVec(prometheus.SummaryOpts{}, []string{"pattern", "method", "status", "duration"}) vec := prometheus.NewSummaryVec(prometheus.SummaryOpts{}, []string{"pattern", "method", "status"})
report(time.Second, writer, request, vec) report(time.Second, writer, request, vec)
middleware.ServeHTTP(writer, request) middleware.ServeHTTP(writer, request)

View File

@ -15,7 +15,7 @@
package migration package migration
import ( import (
"github.com/astaxie/beego/client/orm/migration" "github.com/beego/beego/v2/client/orm/migration"
) )
// Index struct defines the structure of Index Columns // Index struct defines the structure of Index Columns

View File

@ -28,7 +28,7 @@
package migration package migration
import ( import (
"github.com/astaxie/beego/client/orm/migration" "github.com/beego/beego/v2/client/orm/migration"
) )
// const the data format for the bee generate migration datatype // const the data format for the bee generate migration datatype

View File

@ -17,10 +17,10 @@ package adapter
import ( import (
"net/http" "net/http"
adtContext "github.com/astaxie/beego/adapter/context" adtContext "github.com/beego/beego/v2/adapter/context"
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
type namespaceCond func(*adtContext.Context) bool type namespaceCond func(*adtContext.Context) bool
@ -91,28 +91,28 @@ func oldToNewFilter(filter []FilterFunc) []web.FilterFunc {
} }
// Router same as beego.Rourer // Router same as beego.Rourer
// refer: https://godoc.org/github.com/astaxie/beego#Router // refer: https://godoc.org/github.com/beego/beego/v2#Router
func (n *Namespace) Router(rootpath string, c ControllerInterface, mappingMethods ...string) *Namespace { func (n *Namespace) Router(rootpath string, c ControllerInterface, mappingMethods ...string) *Namespace {
(*web.Namespace)(n).Router(rootpath, c, mappingMethods...) (*web.Namespace)(n).Router(rootpath, c, mappingMethods...)
return n return n
} }
// AutoRouter same as beego.AutoRouter // AutoRouter same as beego.AutoRouter
// refer: https://godoc.org/github.com/astaxie/beego#AutoRouter // refer: https://godoc.org/github.com/beego/beego/v2#AutoRouter
func (n *Namespace) AutoRouter(c ControllerInterface) *Namespace { func (n *Namespace) AutoRouter(c ControllerInterface) *Namespace {
(*web.Namespace)(n).AutoRouter(c) (*web.Namespace)(n).AutoRouter(c)
return n return n
} }
// AutoPrefix same as beego.AutoPrefix // AutoPrefix same as beego.AutoPrefix
// refer: https://godoc.org/github.com/astaxie/beego#AutoPrefix // refer: https://godoc.org/github.com/beego/beego/v2#AutoPrefix
func (n *Namespace) AutoPrefix(prefix string, c ControllerInterface) *Namespace { func (n *Namespace) AutoPrefix(prefix string, c ControllerInterface) *Namespace {
(*web.Namespace)(n).AutoPrefix(prefix, c) (*web.Namespace)(n).AutoPrefix(prefix, c)
return n return n
} }
// Get same as beego.Get // Get same as beego.Get
// refer: https://godoc.org/github.com/astaxie/beego#Get // refer: https://godoc.org/github.com/beego/beego/v2#Get
func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Get(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Get(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -121,7 +121,7 @@ func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace {
} }
// Post same as beego.Post // Post same as beego.Post
// refer: https://godoc.org/github.com/astaxie/beego#Post // refer: https://godoc.org/github.com/beego/beego/v2#Post
func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Post(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Post(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -130,7 +130,7 @@ func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace {
} }
// Delete same as beego.Delete // Delete same as beego.Delete
// refer: https://godoc.org/github.com/astaxie/beego#Delete // refer: https://godoc.org/github.com/beego/beego/v2#Delete
func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Delete(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Delete(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -139,7 +139,7 @@ func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace {
} }
// Put same as beego.Put // Put same as beego.Put
// refer: https://godoc.org/github.com/astaxie/beego#Put // refer: https://godoc.org/github.com/beego/beego/v2#Put
func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Put(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Put(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -148,7 +148,7 @@ func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace {
} }
// Head same as beego.Head // Head same as beego.Head
// refer: https://godoc.org/github.com/astaxie/beego#Head // refer: https://godoc.org/github.com/beego/beego/v2#Head
func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Head(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Head(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -157,7 +157,7 @@ func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace {
} }
// Options same as beego.Options // Options same as beego.Options
// refer: https://godoc.org/github.com/astaxie/beego#Options // refer: https://godoc.org/github.com/beego/beego/v2#Options
func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Options(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Options(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -166,7 +166,7 @@ func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace {
} }
// Patch same as beego.Patch // Patch same as beego.Patch
// refer: https://godoc.org/github.com/astaxie/beego#Patch // refer: https://godoc.org/github.com/beego/beego/v2#Patch
func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Patch(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Patch(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -175,7 +175,7 @@ func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace {
} }
// Any same as beego.Any // Any same as beego.Any
// refer: https://godoc.org/github.com/astaxie/beego#Any // refer: https://godoc.org/github.com/beego/beego/v2#Any
func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace { func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace {
(*web.Namespace)(n).Any(rootpath, func(ctx *context.Context) { (*web.Namespace)(n).Any(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
@ -184,14 +184,14 @@ func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace {
} }
// Handler same as beego.Handler // Handler same as beego.Handler
// refer: https://godoc.org/github.com/astaxie/beego#Handler // refer: https://godoc.org/github.com/beego/beego/v2#Handler
func (n *Namespace) Handler(rootpath string, h http.Handler) *Namespace { func (n *Namespace) Handler(rootpath string, h http.Handler) *Namespace {
(*web.Namespace)(n).Handler(rootpath, h) (*web.Namespace)(n).Handler(rootpath, h)
return n return n
} }
// Include add include class // Include add include class
// refer: https://godoc.org/github.com/astaxie/beego#Include // refer: https://godoc.org/github.com/beego/beego/v2#Include
func (n *Namespace) Include(cList ...ControllerInterface) *Namespace { func (n *Namespace) Include(cList ...ControllerInterface) *Namespace {
nL := oldToNewCtrlIntfs(cList) nL := oldToNewCtrlIntfs(cList)
(*web.Namespace)(n).Include(nL...) (*web.Namespace)(n).Include(nL...)
@ -238,141 +238,158 @@ func AddNamespace(nl ...*Namespace) {
// NSCond is Namespace Condition // NSCond is Namespace Condition
func NSCond(cond namespaceCond) LinkNamespace { func NSCond(cond namespaceCond) LinkNamespace {
return func(namespace *Namespace) { wc := web.NSCond(func(b *context.Context) bool {
web.NSCond(func(b *context.Context) bool {
return cond((*adtContext.Context)(b)) return cond((*adtContext.Context)(b))
}) })
return func(namespace *Namespace) {
wc((*web.Namespace)(namespace))
} }
} }
// NSBefore Namespace BeforeRouter filter // NSBefore Namespace BeforeRouter filter
func NSBefore(filterList ...FilterFunc) LinkNamespace { func NSBefore(filterList ...FilterFunc) LinkNamespace {
return func(namespace *Namespace) {
nfs := oldToNewFilter(filterList) nfs := oldToNewFilter(filterList)
web.NSBefore(nfs...) wf := web.NSBefore(nfs...)
return func(namespace *Namespace) {
wf((*web.Namespace)(namespace))
} }
} }
// NSAfter add Namespace FinishRouter filter // NSAfter add Namespace FinishRouter filter
func NSAfter(filterList ...FilterFunc) LinkNamespace { func NSAfter(filterList ...FilterFunc) LinkNamespace {
return func(namespace *Namespace) {
nfs := oldToNewFilter(filterList) nfs := oldToNewFilter(filterList)
web.NSAfter(nfs...) wf := web.NSAfter(nfs...)
return func(namespace *Namespace) {
wf((*web.Namespace)(namespace))
} }
} }
// NSInclude Namespace Include ControllerInterface // NSInclude Namespace Include ControllerInterface
func NSInclude(cList ...ControllerInterface) LinkNamespace { func NSInclude(cList ...ControllerInterface) LinkNamespace {
return func(namespace *Namespace) {
nfs := oldToNewCtrlIntfs(cList) nfs := oldToNewCtrlIntfs(cList)
web.NSInclude(nfs...) wi := web.NSInclude(nfs...)
return func(namespace *Namespace) {
wi((*web.Namespace)(namespace))
} }
} }
// NSRouter call Namespace Router // NSRouter call Namespace Router
func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) LinkNamespace { func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) LinkNamespace {
wn := web.NSRouter(rootpath, c, mappingMethods...)
return func(namespace *Namespace) { return func(namespace *Namespace) {
web.Router(rootpath, c, mappingMethods...) wn((*web.Namespace)(namespace))
} }
} }
// NSGet call Namespace Get // NSGet call Namespace Get
func NSGet(rootpath string, f FilterFunc) LinkNamespace { func NSGet(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { ln := web.NSGet(rootpath, func(ctx *context.Context) {
web.NSGet(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
ln((*web.Namespace)(ns))
} }
} }
// NSPost call Namespace Post // NSPost call Namespace Post
func NSPost(rootpath string, f FilterFunc) LinkNamespace { func NSPost(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wp := web.NSPost(rootpath, func(ctx *context.Context) {
web.Post(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wp((*web.Namespace)(ns))
} }
} }
// NSHead call Namespace Head // NSHead call Namespace Head
func NSHead(rootpath string, f FilterFunc) LinkNamespace { func NSHead(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wb := web.NSHead(rootpath, func(ctx *context.Context) {
web.NSHead(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wb((*web.Namespace)(ns))
} }
} }
// NSPut call Namespace Put // NSPut call Namespace Put
func NSPut(rootpath string, f FilterFunc) LinkNamespace { func NSPut(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSPut(rootpath, func(ctx *context.Context) {
web.NSPut(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSDelete call Namespace Delete // NSDelete call Namespace Delete
func NSDelete(rootpath string, f FilterFunc) LinkNamespace { func NSDelete(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSDelete(rootpath, func(ctx *context.Context) {
web.NSDelete(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSAny call Namespace Any // NSAny call Namespace Any
func NSAny(rootpath string, f FilterFunc) LinkNamespace { func NSAny(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSAny(rootpath, func(ctx *context.Context) {
web.NSAny(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSOptions call Namespace Options // NSOptions call Namespace Options
func NSOptions(rootpath string, f FilterFunc) LinkNamespace { func NSOptions(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wo := web.NSOptions(rootpath, func(ctx *context.Context) {
web.NSOptions(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wo((*web.Namespace)(ns))
} }
} }
// NSPatch call Namespace Patch // NSPatch call Namespace Patch
func NSPatch(rootpath string, f FilterFunc) LinkNamespace { func NSPatch(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSPatch(rootpath, func(ctx *context.Context) {
web.NSPatch(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSAutoRouter call Namespace AutoRouter // NSAutoRouter call Namespace AutoRouter
func NSAutoRouter(c ControllerInterface) LinkNamespace { func NSAutoRouter(c ControllerInterface) LinkNamespace {
wn := web.NSAutoRouter(c)
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSAutoRouter(c) wn((*web.Namespace)(ns))
} }
} }
// NSAutoPrefix call Namespace AutoPrefix // NSAutoPrefix call Namespace AutoPrefix
func NSAutoPrefix(prefix string, c ControllerInterface) LinkNamespace { func NSAutoPrefix(prefix string, c ControllerInterface) LinkNamespace {
wn := web.NSAutoPrefix(prefix, c)
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSAutoPrefix(prefix, c) wn((*web.Namespace)(ns))
} }
} }
// NSNamespace add sub Namespace // NSNamespace add sub Namespace
func NSNamespace(prefix string, params ...LinkNamespace) LinkNamespace { func NSNamespace(prefix string, params ...LinkNamespace) LinkNamespace {
return func(ns *Namespace) {
nps := oldToNewLinkNs(params) nps := oldToNewLinkNs(params)
web.NSNamespace(prefix, nps...) wn := web.NSNamespace(prefix, nps...)
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSHandler add handler // NSHandler add handler
func NSHandler(rootpath string, h http.Handler) LinkNamespace { func NSHandler(rootpath string, h http.Handler) LinkNamespace {
wn := web.NSHandler(rootpath, h)
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSHandler(rootpath, h) wn((*web.Namespace)(ns))
} }
} }

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// RunCommand listen for orm command and then run it if command arguments passed. // RunCommand listen for orm command and then run it if command arguments passed.

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
var ( var (

View File

@ -19,7 +19,7 @@ import (
"database/sql" "database/sql"
"time" "time"
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// DriverType database driver constant int. // DriverType database driver constant int.

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// ResetModelCache Clean model cache. Then you can re-RegisterModel. // ResetModelCache Clean model cache. Then you can re-RegisterModel.

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// RegisterModel register models // RegisterModel register models
@ -25,7 +25,7 @@ func RegisterModel(models ...interface{}) {
// RegisterModelWithPrefix register models with a prefix // RegisterModelWithPrefix register models with a prefix
func RegisterModelWithPrefix(prefix string, models ...interface{}) { func RegisterModelWithPrefix(prefix string, models ...interface{}) {
orm.RegisterModelWithPrefix(prefix, models) orm.RegisterModelWithPrefix(prefix, models...)
} }
// RegisterModelWithSuffix register models with a suffix // RegisterModelWithSuffix register models with a suffix

View File

@ -0,0 +1,30 @@
// Copyright 2020 beego
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package orm
import (
"testing"
)
type User struct {
Id int
}
type Seller struct {
Id int
}
func TestRegisterModelWithPrefix(t *testing.T) {
RegisterModelWithPrefix("test", &User{}, &Seller{})
}

View File

@ -17,7 +17,7 @@ package orm
import ( import (
"time" "time"
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// Define the Type enum // Define the Type enum

View File

@ -21,7 +21,7 @@
// //
// import ( // import (
// "fmt" // "fmt"
// "github.com/astaxie/beego/orm" // "github.com/beego/beego/v2/orm"
// _ "github.com/go-sql-driver/mysql" // import your used driver // _ "github.com/go-sql-driver/mysql" // import your used driver
// ) // )
// //
@ -58,9 +58,9 @@ import (
"database/sql" "database/sql"
"errors" "errors"
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
"github.com/astaxie/beego/client/orm/hints" "github.com/beego/beego/v2/client/orm/hints"
"github.com/astaxie/beego/core/utils" "github.com/beego/beego/v2/core/utils"
) )
// DebugQueries define the debug // DebugQueries define the debug

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// ExprSep define the expression separation // ExprSep define the expression separation

View File

@ -17,7 +17,7 @@ package orm
import ( import (
"io" "io"
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// Log implement the log.Logger // Log implement the log.Logger

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// define Col operations // define Col operations

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// QueryBuilder is the Query builder interface // QueryBuilder is the Query builder interface

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// CommaSpace is the separation // CommaSpace is the separation

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// TiDBQueryBuilder is the SQL build // TiDBQueryBuilder is the SQL build

View File

@ -15,7 +15,7 @@
package orm package orm
import ( import (
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
type baseQuerySetter struct { type baseQuerySetter struct {

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
// Params stores the Params // Params stores the Params

View File

@ -21,7 +21,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/astaxie/beego/client/orm" "github.com/beego/beego/v2/client/orm"
) )
type fn func(string) string type fn func(string) string

View File

@ -16,8 +16,8 @@
// //
// Simple Usage: // Simple Usage:
// import( // import(
// "github.com/astaxie/beego" // "github.com/beego/beego/v2"
// "github.com/astaxie/beego/plugins/apiauth" // "github.com/beego/beego/v2/plugins/apiauth"
// ) // )
// //
// func main(){ // func main(){
@ -58,10 +58,10 @@ package apiauth
import ( import (
"net/url" "net/url"
beego "github.com/astaxie/beego/adapter" beego "github.com/beego/beego/v2/adapter"
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web/filter/apiauth" "github.com/beego/beego/v2/server/web/filter/apiauth"
) )
// AppIDToAppSecret is used to get appsecret throw appid // AppIDToAppSecret is used to get appsecret throw appid

View File

@ -15,8 +15,8 @@
// Package auth provides handlers to enable basic auth support. // Package auth provides handlers to enable basic auth support.
// Simple Usage: // Simple Usage:
// import( // import(
// "github.com/astaxie/beego" // "github.com/beego/beego/v2"
// "github.com/astaxie/beego/plugins/auth" // "github.com/beego/beego/v2/plugins/auth"
// ) // )
// //
// func main(){ // func main(){
@ -38,10 +38,10 @@ package auth
import ( import (
"net/http" "net/http"
beego "github.com/astaxie/beego/adapter" beego "github.com/beego/beego/v2/adapter"
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web/filter/auth" "github.com/beego/beego/v2/server/web/filter/auth"
) )
// Basic is the http basic auth // Basic is the http basic auth

View File

@ -15,8 +15,8 @@
// Package authz provides handlers to enable ACL, RBAC, ABAC authorization support. // Package authz provides handlers to enable ACL, RBAC, ABAC authorization support.
// Simple Usage: // Simple Usage:
// import( // import(
// "github.com/astaxie/beego" // "github.com/beego/beego/v2"
// "github.com/astaxie/beego/plugins/authz" // "github.com/beego/beego/v2/plugins/authz"
// "github.com/casbin/casbin" // "github.com/casbin/casbin"
// ) // )
// //
@ -44,10 +44,10 @@ import (
"github.com/casbin/casbin" "github.com/casbin/casbin"
beego "github.com/astaxie/beego/adapter" beego "github.com/beego/beego/v2/adapter"
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web/filter/authz" "github.com/beego/beego/v2/server/web/filter/authz"
) )
// NewAuthorizer returns the authorizer. // NewAuthorizer returns the authorizer.

View File

@ -19,10 +19,11 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
beego "github.com/astaxie/beego/adapter"
"github.com/astaxie/beego/adapter/context"
"github.com/astaxie/beego/adapter/plugins/auth"
"github.com/casbin/casbin" "github.com/casbin/casbin"
beego "github.com/beego/beego/v2/adapter"
"github.com/beego/beego/v2/adapter/context"
"github.com/beego/beego/v2/adapter/plugins/auth"
) )
func testRequest(t *testing.T, handler *beego.ControllerRegister, user string, path string, method string, code int) { func testRequest(t *testing.T, handler *beego.ControllerRegister, user string, path string, method string, code int) {

View File

@ -15,8 +15,8 @@
// Package cors provides handlers to enable CORS support. // Package cors provides handlers to enable CORS support.
// Usage // Usage
// import ( // import (
// "github.com/astaxie/beego" // "github.com/beego/beego/v2"
// "github.com/astaxie/beego/plugins/cors" // "github.com/beego/beego/v2/plugins/cors"
// ) // )
// //
// func main() { // func main() {
@ -36,11 +36,11 @@
package cors package cors
import ( import (
beego "github.com/astaxie/beego/adapter" beego "github.com/beego/beego/v2/adapter"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web/filter/cors" "github.com/beego/beego/v2/server/web/filter/cors"
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
) )
// Options represents Access Control options. // Options represents Access Control options.

View File

@ -15,9 +15,9 @@
package adapter package adapter
import ( import (
"github.com/astaxie/beego/adapter/context" "github.com/beego/beego/v2/adapter/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
beecontext "github.com/astaxie/beego/server/web/context" beecontext "github.com/beego/beego/v2/server/web/context"
) )
// PolicyFunc defines a policy function which is invoked before the controller handler is executed. // PolicyFunc defines a policy function which is invoked before the controller handler is executed.

View File

@ -18,10 +18,10 @@ import (
"net/http" "net/http"
"time" "time"
beecontext "github.com/astaxie/beego/adapter/context" beecontext "github.com/beego/beego/v2/adapter/context"
"github.com/astaxie/beego/server/web/context" "github.com/beego/beego/v2/server/web/context"
"github.com/astaxie/beego/server/web" "github.com/beego/beego/v2/server/web"
) )
// default filter execution points // default filter execution points

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/couchbase" // _ "github.com/beego/beego/v2/session/couchbase"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -36,8 +36,8 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
beecb "github.com/astaxie/beego/server/web/session/couchbase" beecb "github.com/beego/beego/v2/server/web/session/couchbase"
) )
// SessionStore store each session // SessionStore store each session

View File

@ -5,8 +5,8 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
beeLedis "github.com/astaxie/beego/server/web/session/ledis" beeLedis "github.com/beego/beego/v2/server/web/session/ledis"
) )
// SessionStore ledis session store // SessionStore ledis session store

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/memcache" // _ "github.com/beego/beego/v2/session/memcache"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -36,9 +36,9 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
beemem "github.com/astaxie/beego/server/web/session/memcache" beemem "github.com/beego/beego/v2/server/web/session/memcache"
) )
// SessionStore memcache session store // SessionStore memcache session store

View File

@ -28,8 +28,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/mysql" // _ "github.com/beego/beego/v2/session/mysql"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -44,8 +44,8 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
"github.com/astaxie/beego/server/web/session/mysql" "github.com/beego/beego/v2/server/web/session/mysql"
// import mysql driver // import mysql driver
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"

View File

@ -38,8 +38,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/postgresql" // _ "github.com/beego/beego/v2/session/postgresql"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -54,11 +54,11 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
// import postgresql Driver // import postgresql Driver
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/astaxie/beego/server/web/session/postgres" "github.com/beego/beego/v2/server/web/session/postgres"
) )
// SessionStore postgresql session store // SessionStore postgresql session store

View File

@ -17,7 +17,7 @@ package session
import ( import (
"context" "context"
"github.com/astaxie/beego/server/web/session" "github.com/beego/beego/v2/server/web/session"
) )
type oldToNewProviderAdapter struct { type oldToNewProviderAdapter struct {

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/redis" // _ "github.com/beego/beego/v2/session/redis"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -36,9 +36,9 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
beeRedis "github.com/astaxie/beego/server/web/session/redis" beeRedis "github.com/beego/beego/v2/server/web/session/redis"
) )
// MaxPoolSize redis max pool size // MaxPoolSize redis max pool size

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/redis_cluster" // _ "github.com/beego/beego/v2/session/redis_cluster"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -36,8 +36,8 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
cluster "github.com/astaxie/beego/server/web/session/redis_cluster" cluster "github.com/beego/beego/v2/server/web/session/redis_cluster"
) )
// MaxPoolSize redis_cluster max pool size // MaxPoolSize redis_cluster max pool size

View File

@ -20,8 +20,8 @@
// //
// Usage: // Usage:
// import( // import(
// _ "github.com/astaxie/beego/session/redis_sentinel" // _ "github.com/beego/beego/v2/session/redis_sentinel"
// "github.com/astaxie/beego/session" // "github.com/beego/beego/v2/session"
// ) // )
// //
// func init() { // func init() {
@ -36,9 +36,9 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
sentinel "github.com/astaxie/beego/server/web/session/redis_sentinel" sentinel "github.com/beego/beego/v2/server/web/session/redis_sentinel"
) )
// DefaultPoolSize redis_sentinel default pool size // DefaultPoolSize redis_sentinel default pool size

View File

@ -5,7 +5,7 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/astaxie/beego/adapter/session" "github.com/beego/beego/v2/adapter/session"
) )
func TestRedisSentinel(t *testing.T) { func TestRedisSentinel(t *testing.T) {

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/server/web/session" "github.com/beego/beego/v2/server/web/session"
) )
// CookieSessionStore Cookie SessionStore // CookieSessionStore Cookie SessionStore

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/server/web/session" "github.com/beego/beego/v2/server/web/session"
) )
// FileSessionStore File session store // FileSessionStore File session store

View File

@ -18,7 +18,7 @@ import (
"context" "context"
"net/http" "net/http"
"github.com/astaxie/beego/server/web/session" "github.com/beego/beego/v2/server/web/session"
) )
// MemSessionStore memory session store. // MemSessionStore memory session store.

View File

@ -15,7 +15,7 @@
package session package session
import ( import (
"github.com/astaxie/beego/server/web/session" "github.com/beego/beego/v2/server/web/session"
) )
// EncodeGob encode the obj to gob // EncodeGob encode the obj to gob

Some files were not shown because too many files have changed in this diff Show More