uing pkg module

This commit is contained in:
Ming Deng 2020-07-29 21:56:19 +08:00
parent 7312197732
commit aa06a10493
75 changed files with 192 additions and 181 deletions

View File

@ -54,16 +54,22 @@ import (
const (
// PreSignal is the position to add filter before signal
// Deprecated: using pkg/grace, we will delete this in v2.1.0
PreSignal = iota
// PostSignal is the position to add filter after signal
// Deprecated: using pkg/grace, we will delete this in v2.1.0
PostSignal
// StateInit represent the application inited
// Deprecated: using pkg/grace, we will delete this in v2.1.0
StateInit
// StateRunning represent the application is running
// Deprecated: using pkg/grace, we will delete this in v2.1.0
StateRunning
// StateShuttingDown represent the application is shutting down
// Deprecated: using pkg/grace, we will delete this in v2.1.0
StateShuttingDown
// StateTerminate represent the application is killed
// Deprecated: using pkg/grace, we will delete this in v2.1.0
StateTerminate
)
@ -106,6 +112,7 @@ func init() {
}
// NewServer returns a new graceServer.
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func NewServer(addr string, handler http.Handler) (srv *Server) {
regLock.Lock()
defer regLock.Unlock()
@ -154,12 +161,14 @@ func NewServer(addr string, handler http.Handler) (srv *Server) {
}
// ListenAndServe refer http.ListenAndServe
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func ListenAndServe(addr string, handler http.Handler) error {
server := NewServer(addr, handler)
return server.ListenAndServe()
}
// ListenAndServeTLS refer http.ListenAndServeTLS
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error {
server := NewServer(addr, handler)
return server.ListenAndServeTLS(certFile, keyFile)

View File

@ -18,6 +18,7 @@ import (
)
// Server embedded http.Server
// Deprecated: using pkg/grace, we will delete this in v2.1.0
type Server struct {
*http.Server
ln net.Listener
@ -32,6 +33,7 @@ type Server struct {
// Serve accepts incoming connections on the Listener l,
// creating a new service goroutine for each.
// The service goroutines read requests and then call srv.Handler to reply to them.
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func (srv *Server) Serve() (err error) {
srv.state = StateRunning
defer func() { srv.state = StateTerminate }()
@ -55,6 +57,7 @@ func (srv *Server) Serve() (err error) {
// ListenAndServe listens on the TCP network address srv.Addr and then calls Serve
// to handle requests on incoming connections. If srv.Addr is blank, ":http" is
// used.
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func (srv *Server) ListenAndServe() (err error) {
addr := srv.Addr
if addr == "" {
@ -94,6 +97,7 @@ func (srv *Server) ListenAndServe() (err error) {
// CA's certificate.
//
// If srv.Addr is blank, ":https" is used.
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error) {
addr := srv.Addr
if addr == "" {
@ -140,6 +144,7 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) (err error) {
// ListenAndServeMutualTLS listens on the TCP network address srv.Addr and then calls
// Serve to handle requests on incoming mutual TLS connections.
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func (srv *Server) ListenAndServeMutualTLS(certFile, keyFile, trustFile string) (err error) {
addr := srv.Addr
if addr == "" {
@ -340,6 +345,7 @@ func (srv *Server) fork() (err error) {
}
// RegisterSignalHook registers a function to be run PreSignal or PostSignal for a given signal.
// Deprecated: using pkg/grace, we will delete this in v2.1.0
func (srv *Server) RegisterSignalHook(ppFlag int, sig os.Signal, f func()) (err error) {
if ppFlag != PreSignal && ppFlag != PostSignal {
err = fmt.Errorf("Invalid ppFlag argument. Must be either grace.PreSignal or grace.PostSignal")

View File

@ -27,10 +27,10 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/astaxie/beego/grace"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/toolbox"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/grace"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/toolbox"
"github.com/astaxie/beego/pkg/utils"
)
// BeeAdminApp is the default adminApp used by admin module.

View File

@ -10,7 +10,7 @@ import (
"strings"
"testing"
"github.com/astaxie/beego/toolbox"
"github.com/astaxie/beego/pkg/toolbox"
)
type SampleDatabaseCheck struct {

View File

@ -27,10 +27,11 @@ import (
"strings"
"time"
"github.com/astaxie/beego/grace"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/utils"
"golang.org/x/crypto/acme/autocert"
"github.com/astaxie/beego/pkg/grace"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/utils"
)
var (
@ -348,7 +349,7 @@ func findAndRemoveSingleTree(entryPointTree *Tree) {
// func (b *BankAccount)Mapping(){
// b.Mapping("ShowAccount" , b.ShowAccount)
// b.Mapping("ModifyAccount", b.ModifyAccount)
//}
// }
//
// //@router /account/:id [get]
// func (b *BankAccount) ShowAccount(){

View File

@ -35,8 +35,9 @@ import (
"strings"
"time"
"github.com/astaxie/beego/cache"
"github.com/bradfitz/gomemcache/memcache"
"github.com/astaxie/beego/pkg/cache"
)
// Cache Memcache adapter.

View File

@ -21,7 +21,7 @@ import (
"testing"
"time"
"github.com/astaxie/beego/cache"
"github.com/astaxie/beego/pkg/cache"
)
func TestMemcacheCache(t *testing.T) {
@ -70,7 +70,7 @@ func TestMemcacheCache(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)
}
@ -82,7 +82,7 @@ func TestMemcacheCache(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

@ -34,12 +34,12 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"time"
"github.com/gomodule/redigo/redis"
"github.com/astaxie/beego/cache"
"strings"
"github.com/astaxie/beego/pkg/cache"
)
var (
@ -56,7 +56,7 @@ type Cache struct {
password string
maxIdle int
//the timeout to a value less than the redis server's timeout.
// the timeout to a value less than the redis server's timeout.
timeout time.Duration
}

View File

@ -19,9 +19,10 @@ import (
"testing"
"time"
"github.com/astaxie/beego/cache"
"github.com/gomodule/redigo/redis"
"github.com/stretchr/testify/assert"
"github.com/astaxie/beego/pkg/cache"
)
func TestRedisCache(t *testing.T) {
@ -70,7 +71,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)
}
@ -82,7 +83,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

@ -9,7 +9,7 @@ import (
"github.com/ssdb/gossdb/ssdb"
"github.com/astaxie/beego/cache"
"github.com/astaxie/beego/pkg/cache"
)
// Cache SSDB adapter

View File

@ -5,7 +5,7 @@ import (
"testing"
"time"
"github.com/astaxie/beego/cache"
"github.com/astaxie/beego/pkg/cache"
)
func TestSsdbcacheCache(t *testing.T) {

View File

@ -22,11 +22,11 @@ import (
"runtime"
"strings"
"github.com/astaxie/beego/config"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/config"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/session"
"github.com/astaxie/beego/pkg/utils"
)
// Config is the main struct for BConfig

View File

@ -21,7 +21,7 @@ import (
"os"
"strings"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/utils"
)
var env *utils.BeeMap

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package config
package ini
import (
"bufio"
@ -26,6 +26,8 @@ import (
"strconv"
"strings"
"sync"
"github.com/astaxie/beego/pkg/config"
)
var (
@ -45,7 +47,7 @@ type IniConfig struct {
}
// Parse creates a new Config and parses the file configuration from the named file.
func (ini *IniConfig) Parse(name string) (Configer, error) {
func (ini *IniConfig) Parse(name string) (config.Configer, error) {
return ini.parseFile(name)
}
@ -195,7 +197,7 @@ func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, e
val = bytes.Trim(val, `"`)
}
cfg.data[section][key] = ExpandValueEnv(string(val))
cfg.data[section][key] = config.ExpandValueEnv(string(val))
if comment.Len() > 0 {
cfg.keyComment[section+"."+key] = comment.String()
comment.Reset()
@ -208,7 +210,7 @@ func (ini *IniConfig) parseData(dir string, data []byte) (*IniConfigContainer, e
// ParseData parse ini the data
// When include other.conf,other.conf is either absolute directory
// or under beego in default temporary directory(/tmp/beego[-username]).
func (ini *IniConfig) ParseData(data []byte) (Configer, error) {
func (ini *IniConfig) ParseData(data []byte) (config.Configer, error) {
dir := "beego"
currentUser, err := user.Current()
if err == nil {
@ -233,7 +235,7 @@ type IniConfigContainer struct {
// Bool returns the boolean value for a given key.
func (c *IniConfigContainer) Bool(key string) (bool, error) {
return ParseBool(c.getdata(key))
return config.ParseBool(c.getdata(key))
}
// DefaultBool returns the boolean value for a given key.
@ -500,5 +502,5 @@ func (c *IniConfigContainer) getdata(key string) string {
}
func init() {
Register("ini", &IniConfig{})
config.Register("ini", &IniConfig{})
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package config
package ini
import (
"fmt"
@ -20,6 +20,8 @@ import (
"os"
"strings"
"testing"
"github.com/astaxie/beego/pkg/config"
)
func TestIni(t *testing.T) {
@ -92,7 +94,7 @@ password = ${GOPATH}
}
f.Close()
defer os.Remove("testini.conf")
iniconf, err := NewConfig("ini", "testini.conf")
iniconf, err := config.NewConfig("ini", "testini.conf")
if err != nil {
t.Fatal(err)
}
@ -165,7 +167,7 @@ httpport=8080
name=mysql
`
)
cfg, err := NewConfigData("ini", []byte(inicontext))
cfg, err := config.NewConfigData("ini", []byte(inicontext))
if err != nil {
t.Fatal(err)
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package config
package json
import (
"encoding/json"
@ -23,6 +23,8 @@ import (
"strconv"
"strings"
"sync"
"github.com/astaxie/beego/pkg/config"
)
// JSONConfig is a json config parser and implements Config interface.
@ -30,7 +32,7 @@ type JSONConfig struct {
}
// Parse returns a ConfigContainer with parsed json config map.
func (js *JSONConfig) Parse(filename string) (Configer, error) {
func (js *JSONConfig) Parse(filename string) (config.Configer, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
@ -45,7 +47,7 @@ func (js *JSONConfig) Parse(filename string) (Configer, error) {
}
// ParseData returns a ConfigContainer with json string
func (js *JSONConfig) ParseData(data []byte) (Configer, error) {
func (js *JSONConfig) ParseData(data []byte) (config.Configer, error) {
x := &JSONConfigContainer{
data: make(map[string]interface{}),
}
@ -59,7 +61,7 @@ func (js *JSONConfig) ParseData(data []byte) (Configer, error) {
x.data["rootArray"] = wrappingArray
}
x.data = ExpandValueEnvForMap(x.data)
x.data = config.ExpandValueEnvForMap(x.data)
return x, nil
}
@ -75,7 +77,7 @@ type JSONConfigContainer struct {
func (c *JSONConfigContainer) Bool(key string) (bool, error) {
val := c.getData(key)
if val != nil {
return ParseBool(val)
return config.ParseBool(val)
}
return false, fmt.Errorf("not exist key: %q", key)
}
@ -265,5 +267,5 @@ func (c *JSONConfigContainer) getData(key string) interface{} {
}
func init() {
Register("json", &JSONConfig{})
config.Register("json", &JSONConfig{})
}

View File

@ -12,12 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package config
package json
import (
"fmt"
"os"
"testing"
"github.com/astaxie/beego/pkg/config"
)
func TestJsonStartsWithArray(t *testing.T) {
@ -43,7 +45,7 @@ func TestJsonStartsWithArray(t *testing.T) {
}
f.Close()
defer os.Remove("testjsonWithArray.conf")
jsonconf, err := NewConfig("json", "testjsonWithArray.conf")
jsonconf, err := config.NewConfig("json", "testjsonWithArray.conf")
if err != nil {
t.Fatal(err)
}
@ -143,7 +145,7 @@ func TestJson(t *testing.T) {
}
f.Close()
defer os.Remove("testjson.conf")
jsonconf, err := NewConfig("json", "testjson.conf")
jsonconf, err := config.NewConfig("json", "testjson.conf")
if err != nil {
t.Fatal(err)
}

View File

@ -39,7 +39,7 @@ import (
"strings"
"sync"
"github.com/astaxie/beego/config"
"github.com/astaxie/beego/pkg/config"
"github.com/beego/x2j"
)

View File

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

View File

@ -40,7 +40,7 @@ import (
"strings"
"sync"
"github.com/astaxie/beego/config"
"github.com/astaxie/beego/pkg/config"
"github.com/beego/goyaml2"
)

View File

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

View File

@ -19,7 +19,7 @@ import (
"reflect"
"testing"
"github.com/astaxie/beego/config"
beeJson "github.com/astaxie/beego/pkg/config/json"
)
func TestDefaults(t *testing.T) {
@ -35,7 +35,7 @@ func TestDefaults(t *testing.T) {
func TestAssignConfig_01(t *testing.T) {
_BConfig := &Config{}
_BConfig.AppName = "beego_test"
jcf := &config.JSONConfig{}
jcf := &beeJson.JSONConfig{}
ac, _ := jcf.ParseData([]byte(`{"AppName":"beego_json"}`))
assignSingleConfig(_BConfig, ac)
if _BConfig.AppName != "beego_json" {
@ -73,7 +73,7 @@ func TestAssignConfig_02(t *testing.T) {
configMap["SessionProviderConfig"] = "file"
configMap["FileLineNum"] = true
jcf := &config.JSONConfig{}
jcf := &beeJson.JSONConfig{}
bs, _ = json.Marshal(configMap)
ac, _ := jcf.ParseData(bs)
@ -109,7 +109,7 @@ func TestAssignConfig_02(t *testing.T) {
}
func TestAssignConfig_03(t *testing.T) {
jcf := &config.JSONConfig{}
jcf := &beeJson.JSONConfig{}
ac, _ := jcf.ParseData([]byte(`{"AppName":"beego"}`))
ac.Set("AppName", "test_app")
ac.Set("RunMode", "online")

View File

@ -35,7 +35,7 @@ import (
"strings"
"time"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/utils"
)
//commonly used mime-types

View File

@ -29,7 +29,7 @@ import (
"strings"
"sync"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
)
// Regexes for checking the accept headers

View File

@ -4,8 +4,8 @@ import (
"fmt"
"reflect"
beecontext "github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
beecontext "github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/logs"
)
// ConvertParams converts http method params to values that will be passed to the method controller as arguments

View File

@ -28,9 +28,9 @@ import (
"strconv"
"strings"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/context/param"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/context/param"
"github.com/astaxie/beego/pkg/session"
)
var (

View File

@ -19,7 +19,7 @@ import (
"strconv"
"testing"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg/context"
"os"
"path/filepath"
)

View File

@ -6,7 +6,7 @@ It is used for rapid development of RESTful APIs, web apps and backend services
beego is inspired by Tornado, Sinatra and Flask with the added benefit of some Go-specific features such as interfaces and struct embedding.
package main
import "github.com/astaxie/beego"
import "github.com/astaxie/beego/pkg"
func main() {
beego.Run()

View File

@ -23,8 +23,8 @@ import (
"strconv"
"strings"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/utils"
)
const (

View File

@ -14,7 +14,7 @@
package beego
import "github.com/astaxie/beego/context"
import "github.com/astaxie/beego/pkg/context"
// FilterFunc defines a filter function which is invoked before the controller handler is executed.
type FilterFunc func(*context.Context)

View File

@ -19,7 +19,7 @@ import (
"net/http/httptest"
"testing"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg/context"
)
var FilterUser = func(ctx *context.Context) {

View File

@ -6,9 +6,9 @@ import (
"net/http"
"path/filepath"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/session"
)
// register MIME type with content type

View File

@ -17,11 +17,11 @@ package beego
import (
"strings"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/logs"
)
// Log levels to control the logging output.
// Deprecated: use github.com/astaxie/beego/logs instead.
// Deprecated: use github.com/astaxie/beego/pkg/logs instead.
const (
LevelEmergency = iota
LevelAlert
@ -34,90 +34,90 @@ const (
)
// BeeLogger references the used application logger.
// Deprecated: use github.com/astaxie/beego/logs instead.
// Deprecated: use github.com/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/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/astaxie/beego/pkg/logs instead.
func Trace(v ...interface{}) {
logs.Trace(generateFmtStr(len(v)), v...)
}

View File

@ -6,7 +6,7 @@ import (
"sync"
"time"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/logs"
"github.com/gogo/protobuf/proto"
)

View File

@ -12,7 +12,7 @@ import (
"github.com/elastic/go-elasticsearch/v6"
"github.com/elastic/go-elasticsearch/v6/esapi"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/logs"
)
// NewES return a LoggerInterface

View File

@ -23,8 +23,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/logs"
)
func PrometheusMiddleWare(next http.Handler) http.Handler {

View File

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

View File

@ -17,7 +17,7 @@ package migration
import (
"fmt"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/logs"
)
// Index struct defines the structure of Index Columns

View File

@ -33,8 +33,8 @@ import (
"strings"
"time"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/orm"
)
// const the data format for the bee generate migration datatype

View File

@ -18,7 +18,7 @@ import (
"net/http"
"strings"
beecontext "github.com/astaxie/beego/context"
beecontext "github.com/astaxie/beego/pkg/context"
)
type namespaceCond func(*beecontext.Context) bool
@ -97,91 +97,91 @@ func (n *Namespace) Filter(action string, filter ...FilterFunc) *Namespace {
}
// Router same as beego.Rourer
// refer: https://godoc.org/github.com/astaxie/beego#Router
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Router
func (n *Namespace) Router(rootpath string, c ControllerInterface, mappingMethods ...string) *Namespace {
n.handlers.Add(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/astaxie/beego/pkg#AutoRouter
func (n *Namespace) AutoRouter(c ControllerInterface) *Namespace {
n.handlers.AddAuto(c)
return n
}
// AutoPrefix same as beego.AutoPrefix
// refer: https://godoc.org/github.com/astaxie/beego#AutoPrefix
// refer: https://godoc.org/github.com/astaxie/beego/pkg#AutoPrefix
func (n *Namespace) AutoPrefix(prefix string, c ControllerInterface) *Namespace {
n.handlers.AddAutoPrefix(prefix, c)
return n
}
// Get same as beego.Get
// refer: https://godoc.org/github.com/astaxie/beego#Get
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Get
func (n *Namespace) Get(rootpath string, f FilterFunc) *Namespace {
n.handlers.Get(rootpath, f)
return n
}
// Post same as beego.Post
// refer: https://godoc.org/github.com/astaxie/beego#Post
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Post
func (n *Namespace) Post(rootpath string, f FilterFunc) *Namespace {
n.handlers.Post(rootpath, f)
return n
}
// Delete same as beego.Delete
// refer: https://godoc.org/github.com/astaxie/beego#Delete
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Delete
func (n *Namespace) Delete(rootpath string, f FilterFunc) *Namespace {
n.handlers.Delete(rootpath, f)
return n
}
// Put same as beego.Put
// refer: https://godoc.org/github.com/astaxie/beego#Put
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Put
func (n *Namespace) Put(rootpath string, f FilterFunc) *Namespace {
n.handlers.Put(rootpath, f)
return n
}
// Head same as beego.Head
// refer: https://godoc.org/github.com/astaxie/beego#Head
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Head
func (n *Namespace) Head(rootpath string, f FilterFunc) *Namespace {
n.handlers.Head(rootpath, f)
return n
}
// Options same as beego.Options
// refer: https://godoc.org/github.com/astaxie/beego#Options
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Options
func (n *Namespace) Options(rootpath string, f FilterFunc) *Namespace {
n.handlers.Options(rootpath, f)
return n
}
// Patch same as beego.Patch
// refer: https://godoc.org/github.com/astaxie/beego#Patch
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Patch
func (n *Namespace) Patch(rootpath string, f FilterFunc) *Namespace {
n.handlers.Patch(rootpath, f)
return n
}
// Any same as beego.Any
// refer: https://godoc.org/github.com/astaxie/beego#Any
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Any
func (n *Namespace) Any(rootpath string, f FilterFunc) *Namespace {
n.handlers.Any(rootpath, f)
return n
}
// Handler same as beego.Handler
// refer: https://godoc.org/github.com/astaxie/beego#Handler
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Handler
func (n *Namespace) Handler(rootpath string, h http.Handler) *Namespace {
n.handlers.Handler(rootpath, h)
return n
}
// Include add include class
// refer: https://godoc.org/github.com/astaxie/beego#Include
// refer: https://godoc.org/github.com/astaxie/beego/pkg#Include
func (n *Namespace) Include(cList ...ControllerInterface) *Namespace {
n.handlers.Include(cList...)
return n

View File

@ -20,7 +20,7 @@ import (
"strconv"
"testing"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg/context"
)
func TestNamespaceGet(t *testing.T) {

View File

@ -63,7 +63,7 @@ import (
"reflect"
"time"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/logs"
)
// DebugQueries define the debug

View File

@ -30,16 +30,16 @@ import (
"strings"
"unicode"
"github.com/astaxie/beego/context/param"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/context/param"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/utils"
)
var globalRouterTemplate = `package {{.routersDir}}
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context/param"{{.globalimport}}
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context/param"{{.globalimport}}
)
func init() {

View File

@ -65,8 +65,8 @@ import (
"sort"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context"
)
// AppIDToAppSecret is used to get appsecret throw appid

View File

@ -40,8 +40,8 @@ import (
"net/http"
"strings"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context"
)
var defaultRealm = "Authorization Required"

View File

@ -40,8 +40,8 @@
package authz
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context"
"github.com/casbin/casbin"
"net/http"
)

View File

@ -15,9 +15,9 @@
package authz
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/plugins/auth"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/plugins/auth"
"github.com/casbin/casbin"
"net/http"
"net/http/httptest"

View File

@ -42,8 +42,8 @@ import (
"strings"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context"
)
const (

View File

@ -21,8 +21,8 @@ import (
"testing"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/context"
)
// HTTPHeaderGuardRecorder is httptest.ResponseRecorder with own http.Header

View File

@ -17,7 +17,7 @@ package beego
import (
"strings"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg/context"
)
// PolicyFunc defines a policy function which is invoked before the controller handler is executed.

View File

@ -27,11 +27,11 @@ import (
"sync"
"time"
beecontext "github.com/astaxie/beego/context"
"github.com/astaxie/beego/context/param"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/toolbox"
"github.com/astaxie/beego/utils"
beecontext "github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/context/param"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/toolbox"
"github.com/astaxie/beego/pkg/utils"
)
// default filter execution points

View File

@ -21,8 +21,8 @@ import (
"strings"
"testing"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/logs"
)
type TestController struct {

View File

@ -39,7 +39,7 @@ import (
couchbase "github.com/couchbase/go-couchbase"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
)
var couchbpder = &Provider{}

View File

@ -10,7 +10,7 @@ import (
"github.com/ledisdb/ledisdb/config"
"github.com/ledisdb/ledisdb/ledis"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
)
var (

View File

@ -37,7 +37,7 @@ import (
"strings"
"sync"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
"github.com/bradfitz/gomemcache/memcache"
)

View File

@ -46,7 +46,7 @@ import (
"sync"
"time"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
// import mysql driver
_ "github.com/go-sql-driver/mysql"
)

View File

@ -56,7 +56,7 @@ import (
"sync"
"time"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
// import postgresql Driver
_ "github.com/lib/pq"
)

View File

@ -39,7 +39,7 @@ import (
"sync"
"time"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
"github.com/gomodule/redigo/redis"
)

View File

@ -33,7 +33,7 @@
package redis_cluster
import (
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
rediss "github.com/go-redis/redis"
"net/http"
"strconv"

View File

@ -33,7 +33,7 @@
package redis_sentinel
import (
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
"github.com/go-redis/redis"
"net/http"
"strconv"

View File

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

View File

@ -29,7 +29,7 @@ import (
"strconv"
"time"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/utils"
)
func init() {

View File

@ -7,7 +7,7 @@ import (
"strings"
"sync"
"github.com/astaxie/beego/session"
"github.com/astaxie/beego/pkg/session"
"github.com/ssdb/gossdb/ssdb"
)

View File

@ -26,8 +26,8 @@ import (
"sync"
"time"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/logs"
"github.com/hashicorp/golang-lru"
)

View File

@ -27,8 +27,8 @@ import (
"strings"
"sync"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/utils"
)
var (

View File

@ -16,7 +16,7 @@ package beego
import (
"bytes"
"github.com/astaxie/beego/testdata"
"github.com/astaxie/beego/pkg/testdata"
"github.com/elazarl/go-bindata-assetfs"
"net/http"
"os"

View File

@ -1,15 +0,0 @@
// Copyright 2014 beego Author. All Rights Reserved.
//
// 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 testing

View File

@ -15,8 +15,8 @@
package testing
import (
"github.com/astaxie/beego/config"
"github.com/astaxie/beego/httplib"
"github.com/astaxie/beego/pkg/config"
"github.com/astaxie/beego/pkg/httplib"
)
var port = ""

View File

@ -19,8 +19,8 @@ import (
"regexp"
"strings"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/utils"
)
var (

View File

@ -18,7 +18,7 @@ import (
"strings"
"testing"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg/context"
)
type testinfo struct {

View File

@ -66,11 +66,11 @@ import (
"strings"
"time"
"github.com/astaxie/beego"
"github.com/astaxie/beego/cache"
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg"
"github.com/astaxie/beego/pkg/cache"
"github.com/astaxie/beego/pkg/context"
"github.com/astaxie/beego/pkg/logs"
"github.com/astaxie/beego/pkg/utils"
)
var (

View File

@ -17,7 +17,7 @@ package captcha
import (
"testing"
"github.com/astaxie/beego/utils"
"github.com/astaxie/beego/pkg/utils"
)
type byteCounter struct {

View File

@ -15,7 +15,7 @@
package pagination
import (
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/pkg/context"
)
// SetPaginator Instantiates a Paginator and assigns it to context.Input.Data("paginator").

View File

@ -8,7 +8,7 @@ In your beego.Controller:
package controllers
import "github.com/astaxie/beego/utils/pagination"
import "github.com/astaxie/beego/pkg/utils/pagination"
type PostsController struct {
beego.Controller

View File

@ -16,7 +16,7 @@ package validation
import (
"fmt"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/pkg/logs"
"reflect"
"regexp"
"strings"