1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-16 12:10:55 +00:00

Merge pull request #1571 from astaxie/develop

beego 1.6.0 released
This commit is contained in:
astaxie 2016-01-17 23:58:34 +08:00
commit 48f19b4191
19 changed files with 46 additions and 44 deletions

View File

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

View File

@ -164,7 +164,7 @@ func (c *JSONConfigContainer) String(key string) string {
// DefaultString returns the string value for a given key.
// if err != nil return defaltval
func (c *JSONConfigContainer) DefaultString(key string, defaultval string) string {
// TODO FIXME should not use "" to replace non existance
// TODO FIXME should not use "" to replace non existence
if v := c.String(key); v != "" {
return v
}

View File

@ -20,26 +20,25 @@ import (
)
func Test_ExtractEncoding(t *testing.T) {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip,deflate"}}}) != "gzip" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip,deflate"}}}) != "gzip" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate,gzip"}}}) != "deflate" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"deflate,gzip"}}}) != "deflate" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate"}}}) != "deflate" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip;q=.5,deflate"}}}) != "deflate" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=.5,deflate;q=0.3"}}}) != "gzip" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip;q=.5,deflate;q=0.3"}}}) != "gzip" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"gzip;q=0,deflate"}}}) != "deflate" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"gzip;q=0,deflate"}}}) != "deflate" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"deflate;q=0.5,gzip;q=0.5,identity"}}}) != "" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"deflate;q=0.5,gzip;q=0.5,identity"}}}) != "" {
t.Fail()
}
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": []string{"*"}}}) != "gzip" {
if parseEncoding(&http.Request{Header: map[string][]string{"Accept-Encoding": {"*"}}}) != "gzip" {
t.Fail()
}
}

2
doc.go
View File

@ -12,6 +12,6 @@ beego is inspired by Tornado, Sinatra and Flask with the added benefit of some G
beego.Run()
}
more infomation: http://beego.me
more information: http://beego.me
*/
package beego

View File

@ -118,15 +118,15 @@ func NewServer(addr string, handler http.Handler) (srv *Server) {
sigChan: make(chan os.Signal),
isChild: isChild,
SignalHooks: map[int]map[os.Signal][]func(){
PreSignal: map[os.Signal][]func(){
syscall.SIGHUP: []func(){},
syscall.SIGINT: []func(){},
syscall.SIGTERM: []func(){},
PreSignal: {
syscall.SIGHUP: {},
syscall.SIGINT: {},
syscall.SIGTERM: {},
},
PostSignal: map[os.Signal][]func(){
syscall.SIGHUP: []func(){},
syscall.SIGINT: []func(){},
syscall.SIGTERM: []func(){},
PostSignal: {
syscall.SIGHUP: {},
syscall.SIGINT: {},
syscall.SIGTERM: {},
},
},
state: StateInit,

View File

@ -42,4 +42,3 @@ func TestConsole(t *testing.T) {
log2.SetLogger("console", `{"level":3}`)
testConsoleCalls(log2)
}

View File

@ -130,7 +130,6 @@ func BenchmarkFile(b *testing.B) {
os.Remove("test4.log")
}
func BenchmarkFileAsynchronous(b *testing.B) {
log := NewLogger(100000)
log.SetLogger("file", `{"filename":"test4.log"}`)

View File

@ -19,7 +19,7 @@ import (
"strings"
)
// ExprSep define the expression seperation
// ExprSep define the expression separation
const (
ExprSep = "__"
)

View File

@ -20,7 +20,7 @@ import (
"strings"
)
// CommaSpace is the seperation
// CommaSpace is the separation
const CommaSpace = ", "
// MySQLQueryBuilder is the SQL build

View File

@ -41,7 +41,7 @@
//
// 1. appid
//
// appid is asigned to the application
// appid is assigned to the application
//
// 2. signature
//

View File

@ -80,7 +80,7 @@ func TestDestorySessionCookie(t *testing.T) {
t.Fatal("get cookie session id is not the same again.")
}
// After destory session , will get a new session id .
// After destroy session , will get a new session id .
globalSessions.SessionDestroy(w, r1)
r2, _ := http.NewRequest("GET", "/", nil)
r2.Header.Set("Cookie", w.Header().Get("Set-Cookie"))
@ -91,6 +91,6 @@ func TestDestorySessionCookie(t *testing.T) {
t.Fatal("session start error")
}
if newSession.SessionID() == session.SessionID() {
t.Fatal("after destory session and reqeust again ,get cookie session id is same.")
t.Fatal("after destroy session and reqeust again ,get cookie session id is same.")
}
}

View File

@ -31,7 +31,7 @@ var (
beegoTplFuncMap = make(template.FuncMap)
// BeeTemplates caching map and supported template file extensions.
BeeTemplates = make(map[string]*template.Template)
// BeeTemplateExt stores the template extention which will build
// BeeTemplateExt stores the template extension which will build
BeeTemplateExt = []string{"tpl", "html"}
)

View File

@ -670,7 +670,7 @@ func MapGet(arg1 interface{}, arg2 ...interface{}) (interface{}, error) {
if arg1Type.Kind() == reflect.Map && len(arg2) > 0 {
// check whether arg2[0] type equals to arg1 key type
// if they are different, make convertion
// if they are different, make conversion
arg2Val := reflect.ValueOf(arg2[0])
arg2Type := reflect.TypeOf(arg2[0])
if arg2Type.Kind() != arg1Type.Key().Kind() {

View File

@ -141,7 +141,7 @@ func (t *Tree) addtree(segments []string, tree *Tree, wildcards []string, reg st
regexpStr = "([^.]+).(.+)"
params = params[1:]
} else {
for _ = range params {
for range params {
regexpStr = "([^/]+)/" + regexpStr
}
}
@ -254,7 +254,7 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string,
regexpStr = "/([^.]+).(.+)"
params = params[1:]
} else {
for _ = range params {
for range params {
regexpStr = "/([^/]+)" + regexpStr
}
}

View File

@ -158,7 +158,7 @@ func (c *Captcha) Handler(ctx *context.Context) {
}
}
// CreateCaptchaHTML tempalte func for output html
// CreateCaptchaHTML template func for output html
func (c *Captcha) CreateCaptchaHTML() template.HTML {
value, err := c.CreateCaptcha()
if err != nil {
@ -255,7 +255,7 @@ func NewCaptcha(urlPrefix string, store cache.Cache) *Captcha {
}
// NewWithFilter create a new captcha.Captcha and auto AddFilter for serve captacha image
// and add a tempalte func for output html
// and add a template func for output html
func NewWithFilter(urlPrefix string, store cache.Cache) *Captcha {
cpt := NewCaptcha(urlPrefix, store)

View File

@ -96,12 +96,16 @@ func (e *Email) Bytes() ([]byte, error) {
e.Headers.Set("Disposition-Notification-To", strings.Join(e.ReadReceipt, ","))
}
e.Headers.Set("MIME-Version", "1.0")
e.Headers.Set("Content-Type", fmt.Sprintf("multipart/mixed;\r\n boundary=%s\r\n", w.Boundary()))
// Write the envelope headers (including any custom headers)
if err := headerToBytes(buff, e.Headers); err != nil {
return nil, fmt.Errorf("Failed to render message headers: %s", err)
}
e.Headers.Set("Content-Type", fmt.Sprintf("multipart/mixed;\r\n boundary=%s\r\n", w.Boundary()))
fmt.Fprintf(w, "%s:", "Content-Type")
fmt.Fprintf(w, " %s\r\n", fmt.Sprintf("multipart/mixed;\r\n boundary=%s\r\n", w.Boundary()))
// Start the multipart/mixed part
fmt.Fprintf(buff, "--%s\r\n", w.Boundary())
header := textproto.MIMEHeader{}