Merge branch 'develop' of https://github.com/beego/beego into fix-issue-4176

This commit is contained in:
AllenX2018 2020-12-26 16:57:22 +08:00
commit 75849b6d6a
293 changed files with 1805 additions and 879 deletions

View File

@ -14,4 +14,4 @@ A complete runnable program is good.
4. What did you expect to see?
5. What did you see instead?
5. What did you see instead?

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

View File

@ -16,4 +16,4 @@ jobs:
stale-issue-message: 'This issue is inactive for a long time.'
stale-pr-message: 'This PR is inactive for a long time'
stale-issue-label: 'inactive-issue'
stale-pr-label: 'inactive-pr'
stale-pr-label: 'inactive-pr'

2
.gitignore vendored
View File

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

View File

@ -10,12 +10,13 @@ services:
- docker
env:
global:
- GO_REPO_FULLNAME="github.com/astaxie/beego"
- GO_REPO_FULLNAME="github.com/beego/beego/v2"
matrix:
- 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=mysql export ORM_SOURCE="root:@/orm_test?charset=utf8"
before_install:
- export CODECOV_TOKEN="4f4bc484-32a8-43b7-9f48-20966bd48ceb"
# link the local repo with ${GOPATH}/src/<namespace>/<repo>
- GO_REPO_NAMESPACE=${GO_REPO_FULLNAME%/*}
# relies on GOPATH to contain only one directory...
@ -62,6 +63,7 @@ install:
- 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
@ -94,12 +96,14 @@ before_script:
after_script:
- killall -w ssdb-server
- rm -rf ./res/var/*
after_success:
- bash <(curl -s https://codecov.io/bash)
script:
- go test ./...
- 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 .
- find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s
- golint ./...
addons:
postgresql: "9.6"
postgresql: "9.6"

4
CHANGELOG.md Normal file
View File

@ -0,0 +1,4 @@
# developing
- 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!
Here are instructions to get you started. They are probably not perfect,
please let us know if anything feels wrong or incomplete.
Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or
incomplete.
## Prepare environment
@ -18,6 +18,7 @@ go get -u github.com/gordonklaus/ineffassign
```
Put those lines into your pre-commit githook script:
```shell script
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.
You can run:
```shell script
docker-compose -f scripts/test_docker_compose.yml up -d
```
Unit tests read addresses from environment, here is an example:
```shell script
export ORM_DRIVER=mysql
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"
```
## Contribution guidelines
### Pull requests
First of all. beego follow the gitflow. So please send you pull request
to **develop-2** branch. We will close the pull request to master branch.
First of all. beego follow the gitflow. So please send you pull request to **develop-2** 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 is worth a pull
request? Do it! We will appreciate it.
We are always happy to receive pull requests, and do our best to review them as fast as possible. Not sure if that typo
is worth a pull request? Do it! We will appreciate it.
Don't forget to rebase your commits!
If your pull request is not accepted on the first try, don't be
discouraged! Sometimes we can make a mistake, please do more explaining
for us. We will appreciate it.
If your pull request is not accepted on the first try, don't be discouraged! Sometimes we can make a mistake, please do
more explaining for us. We will appreciate 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 we might decide against
incorporating a new feature. But we will give you some advice on how to
do it in other way.
We're trying very hard to keep beego simple and fast. We don't want it to do everything for everybody. This means that
we might decide against incorporating a new feature. But we will give you some advice on how to do it in other way.
### Create issues
Any significant improvement should be documented as [a GitHub
issue](https://github.com/astaxie/beego/issues) before anybody
starts working on it.
Any significant improvement should be documented as [a GitHub issue](https://github.com/beego/beego/v2/issues) before
anybody starts working on it.
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!
Please take a moment to check that an issue doesn't already exist
documenting your bug report or improvement proposal. If it does, it
never hurts to add a quick "+1" or "I have this problem too". This will
help prioritize the most common problems and requests.
Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal.
If it does, it never hurts to add a quick "+1" or "I have this problem too". This will 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
the docs in http://beego.me/docs
Also, if you don't know how to use it. please make sure you have read through the docs in http://beego.me/docs

View File

@ -10,4 +10,4 @@ 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.
limitations under the License.

View File

@ -1,4 +1,4 @@
# 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.
@ -9,6 +9,7 @@ embedding.
![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;
@ -18,11 +19,10 @@ Beego is compos of four parts:
[Officail website](http://beego.me)
[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
![Http Request](https://cdn.nlark.com/yuque/0/2020/png/755700/1607857462507-855ec543-7ce3-402d-a0cb-b2524d5a4b60.png)
@ -38,14 +38,14 @@ Beego is compos of four parts:
#### Download and install
go get github.com/astaxie/beego@v2.0.0
go get github.com/beego/beego/v2@v2.0.0
#### Create file `hello.go`
```go
package main
import "github.com/astaxie/beego/server/web"
import "github.com/beego/beego/v2/server/web"
func main() {
web.Run()
@ -73,13 +73,14 @@ Congratulations! You've just built your first **beego** app.
* Full stack for Web & API
## Modules
* [orm](https://github.com/beego/beedoc/tree/master/en-US/mvc/model)
* [session](https://github.com/beego/beedoc/blob/master/en-US/module/session.md)
* [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)
* [governor](https://github.com/beego/beedoc/blob/master/en-US/module/governor.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)
@ -87,8 +88,7 @@ Congratulations! You've just built your first **beego** app.
## 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
* [Contribution Guide](https://github.com/beego/beedoc/blob/master/en-US/intro/contributing.md).

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/astaxie/beego/adapter/cache"
"github.com/beego/beego/v2/adapter/cache"
)
func TestSsdbcacheCache(t *testing.T) {
@ -26,7 +26,7 @@ func TestSsdbcacheCache(t *testing.T) {
t.Error("check err")
}
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 {
t.Error("set Error", err)
}
@ -43,7 +43,7 @@ func TestSsdbcacheCache(t *testing.T) {
t.Error("get Error")
}
//inc/dec test done
// inc/dec test done
if err = ssdb.Put("ssdb", "2", timeoutDuration); err != nil {
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 {
t.Error("set Error", err)
}
@ -83,7 +83,7 @@ func TestSsdbcacheCache(t *testing.T) {
t.Error("get err")
}
//test GetMulti done
// test GetMulti done
if err = ssdb.Put("ssdb1", "ssdb1", -10*time.Second); err != nil {
t.Error("set Error", err)
}

View File

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

View File

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

View File

@ -14,7 +14,7 @@
// Package config is used to parse config.
// Usage:
// import "github.com/astaxie/beego/config"
// import "github.com/beego/beego/v2/config"
// Examples.
//
// cnf, err := config.NewConfig("ini", "config.conf")
@ -41,7 +41,7 @@
package config
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.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,13 +19,13 @@ import (
"os"
"testing"
"github.com/astaxie/beego/adapter/config"
"github.com/beego/beego/v2/adapter/config"
)
func TestXML(t *testing.T) {
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"?>
<config>
<appname>beeapi</appname>

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@
package context
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.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@
package adapter
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.

View File

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

View File

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

View File

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

View File

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

View File

@ -17,13 +17,13 @@ package adapter
import (
"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.
// Deprecated: use github.com/astaxie/beego/logs instead.
// Deprecated: use github.com/beego/beego/v2/logs instead.
const (
LevelEmergency = webLog.LevelEmergency
LevelAlert = webLog.LevelAlert
@ -36,90 +36,90 @@ const (
)
// 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()
// 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) {
logs.SetLevel(l)
}
// 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) {
logs.SetLogFuncCall(b)
}
// 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 {
return logs.SetLogger(adaptername, config)
}
// 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{}) {
logs.Emergency(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Alert(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Critical(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Error(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Warning(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Warn(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Notice(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Informational(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Info(generateFmtStr(len(v)), v...)
}
// 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{}) {
logs.Debug(generateFmtStr(len(v)), v...)
}
// Trace logs a message at trace level.
// 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{}) {
logs.Trace(generateFmtStr(len(v)), v...)
}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
package es
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
// Usage:
//
// import "github.com/astaxie/beego/logs"
// import "github.com/beego/beego/v2/logs"
//
// log := NewLogger(10000)
// log.SetLogger("console", "")
@ -37,7 +37,7 @@ import (
"log"
"time"
"github.com/astaxie/beego/core/logs"
"github.com/beego/beego/v2/core/logs"
)
// RFC5424 log message levels.

View File

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

View File

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

View File

@ -23,9 +23,9 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego"
"github.com/astaxie/beego/core/logs"
"github.com/astaxie/beego/server/web"
"github.com/beego/beego/v2"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/server/web"
)
func PrometheusMiddleWare(next http.Handler) http.Handler {

View File

@ -22,7 +22,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego/adapter/context"
"github.com/beego/beego/v2/adapter/context"
)
func TestPrometheusMiddleWare(t *testing.T) {

View File

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

View File

@ -28,7 +28,7 @@
package migration
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

View File

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

View File

@ -15,7 +15,7 @@
package orm
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.

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@
package orm
import (
"github.com/astaxie/beego/client/orm"
"github.com/beego/beego/v2/client/orm"
)
// RegisterModel register models
@ -25,7 +25,7 @@ func RegisterModel(models ...interface{}) {
// RegisterModelWithPrefix register models with a prefix
func RegisterModelWithPrefix(prefix string, models ...interface{}) {
orm.RegisterModelWithPrefix(prefix, models)
orm.RegisterModelWithPrefix(prefix, models...)
}
// 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 (
"time"
"github.com/astaxie/beego/client/orm"
"github.com/beego/beego/v2/client/orm"
)
// Define the Type enum

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,4 +11,4 @@ g = _, _
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && (r.act == p.act || p.act == "*")
m = g(r.sub, p.sub) && keyMatch(r.obj, p.obj) && (r.act == p.act || p.act == "*")

View File

@ -4,4 +4,4 @@ p, bob, /dataset2/resource1, *
p, bob, /dataset2/resource2, GET
p, bob, /dataset2/folder1/*, POST
p, dataset1_admin, /dataset1/*, *
g, cathy, dataset1_admin
g, cathy, dataset1_admin

1 p, alice, /dataset1/*, GET
4 p, bob, /dataset2/resource2, GET
5 p, bob, /dataset2/folder1/*, POST
6 p, dataset1_admin, /dataset1/*, *
7 g, cathy, dataset1_admin

View File

@ -19,10 +19,11 @@ import (
"net/http/httptest"
"testing"
beego "github.com/astaxie/beego/adapter"
"github.com/astaxie/beego/adapter/context"
"github.com/astaxie/beego/adapter/plugins/auth"
"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) {

View File

@ -15,8 +15,8 @@
// Package cors provides handlers to enable CORS support.
// Usage
// import (
// "github.com/astaxie/beego"
// "github.com/astaxie/beego/plugins/cors"
// "github.com/beego/beego/v2"
// "github.com/beego/beego/v2/plugins/cors"
// )
//
// func main() {
@ -36,11 +36,11 @@
package cors
import (
beego "github.com/astaxie/beego/adapter"
beecontext "github.com/astaxie/beego/server/web/context"
"github.com/astaxie/beego/server/web/filter/cors"
beego "github.com/beego/beego/v2/adapter"
beecontext "github.com/beego/beego/v2/server/web/context"
"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.

View File

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

View File

@ -18,10 +18,10 @@ import (
"net/http"
"time"
beecontext "github.com/astaxie/beego/adapter/context"
"github.com/astaxie/beego/server/web/context"
beecontext "github.com/beego/beego/v2/adapter/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

View File

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

View File

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

View File

@ -20,8 +20,8 @@
//
// Usage:
// import(
// _ "github.com/astaxie/beego/session/memcache"
// "github.com/astaxie/beego/session"
// _ "github.com/beego/beego/v2/session/memcache"
// "github.com/beego/beego/v2/session"
// )
//
// func init() {
@ -36,9 +36,9 @@ import (
"context"
"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

View File

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

View File

@ -38,8 +38,8 @@
//
// Usage:
// import(
// _ "github.com/astaxie/beego/session/postgresql"
// "github.com/astaxie/beego/session"
// _ "github.com/beego/beego/v2/session/postgresql"
// "github.com/beego/beego/v2/session"
// )
//
// func init() {
@ -54,11 +54,11 @@ import (
"context"
"net/http"
"github.com/astaxie/beego/adapter/session"
"github.com/beego/beego/v2/adapter/session"
// import postgresql Driver
_ "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

View File

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

View File

@ -20,8 +20,8 @@
//
// Usage:
// import(
// _ "github.com/astaxie/beego/session/redis"
// "github.com/astaxie/beego/session"
// _ "github.com/beego/beego/v2/session/redis"
// "github.com/beego/beego/v2/session"
// )
//
// func init() {
@ -36,9 +36,9 @@ import (
"context"
"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

View File

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

View File

@ -20,8 +20,8 @@
//
// Usage:
// import(
// _ "github.com/astaxie/beego/session/redis_sentinel"
// "github.com/astaxie/beego/session"
// _ "github.com/beego/beego/v2/session/redis_sentinel"
// "github.com/beego/beego/v2/session"
// )
//
// func init() {
@ -36,9 +36,9 @@ import (
"context"
"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

View File

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

View File

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

View File

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

View File

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

View File

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

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