Merge pull request #4823 from flycash/develop
replace beego.me with beego.vip
This commit is contained in:
commit
3dd5a1adfd
@ -86,4 +86,4 @@ Please take a moment to check that an issue doesn't already exist documenting yo
|
|||||||
If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common
|
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.
|
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.vip/docs
|
||||||
|
|||||||
2
adapter/cache/cache.go
vendored
2
adapter/cache/cache.go
vendored
@ -28,7 +28,7 @@
|
|||||||
// bm.IsExist("astaxie")
|
// bm.IsExist("astaxie")
|
||||||
// bm.Delete("astaxie")
|
// bm.Delete("astaxie")
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/cache.md
|
// more docs http://beego.vip/docs/module/cache.md
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
2
adapter/cache/memcache/memcache.go
vendored
2
adapter/cache/memcache/memcache.go
vendored
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/cache.md
|
// more docs http://beego.vip/docs/module/cache.md
|
||||||
package memcache
|
package memcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
2
adapter/cache/redis/redis.go
vendored
2
adapter/cache/redis/redis.go
vendored
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/cache.md
|
// more docs http://beego.vip/docs/module/cache.md
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
// cnf.DIY(key string) (interface{}, error)
|
// cnf.DIY(key string) (interface{}, error)
|
||||||
// cnf.GetSection(section string) (map[string]string, error)
|
// cnf.GetSection(section string) (map[string]string, error)
|
||||||
// cnf.SaveConfigFile(filename string) error
|
// cnf.SaveConfigFile(filename string) error
|
||||||
// More docs http://beego.me/docs/module/config.md
|
// More docs http://beego.vip/docs/module/config.md
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||||
//
|
//
|
||||||
// More docs http://beego.me/docs/module/config.md
|
// More docs http://beego.vip/docs/module/config.md
|
||||||
package xml
|
package xml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||||
//
|
//
|
||||||
// More docs http://beego.me/docs/module/config.md
|
// More docs http://beego.vip/docs/module/config.md
|
||||||
package yaml
|
package yaml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
//
|
//
|
||||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/context.md
|
// more docs http://beego.vip/docs/module/context.md
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/client/httplib"
|
// import "github.com/beego/beego/v2/client/httplib"
|
||||||
//
|
//
|
||||||
// b := httplib.Post("http://beego.me/")
|
// b := httplib.Post("http://beego.vip/")
|
||||||
// b.Param("username","astaxie")
|
// b.Param("username","astaxie")
|
||||||
// b.Param("password","123456")
|
// b.Param("password","123456")
|
||||||
// b.PostFile("uploadfile1", "httplib.pdf")
|
// b.PostFile("uploadfile1", "httplib.pdf")
|
||||||
@ -28,7 +28,7 @@
|
|||||||
// }
|
// }
|
||||||
// fmt.Println(str)
|
// fmt.Println(str)
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/httplib.md
|
// more docs http://beego.vip/docs/module/httplib.md
|
||||||
package httplib
|
package httplib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
// log.Debug("debug")
|
// log.Debug("debug")
|
||||||
// log.Critical("critical")
|
// log.Critical("critical")
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/logs.md
|
// more docs http://beego.vip/docs/module/logs.md
|
||||||
package logs
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -51,7 +51,7 @@ func oldToNewLinkNs(params []LinkNamespace) []web.LinkNamespace {
|
|||||||
// if cond return true can run this namespace, else can't
|
// if cond return true can run this namespace, else can't
|
||||||
// usage:
|
// usage:
|
||||||
// ns.Cond(func (ctx *context.Context) bool{
|
// ns.Cond(func (ctx *context.Context) bool{
|
||||||
// if ctx.Input.Domain() == "api.beego.me" {
|
// if ctx.Input.Domain() == "api.beego.vip" {
|
||||||
// return true
|
// return true
|
||||||
// }
|
// }
|
||||||
// return false
|
// return false
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
// num, err = o.Delete(&u)
|
// num, err = o.Delete(&u)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/mvc/model/overview.md
|
// more docs: http://beego.vip/docs/mvc/model/overview.md
|
||||||
package orm
|
package orm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package couchbase
|
package couchbase
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package memcache
|
package memcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package mysql
|
package mysql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -47,7 +47,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package postgres
|
package postgres
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package redis_cluster
|
package redis_cluster
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -106,7 +106,7 @@ func Htmlunquote(text string) string {
|
|||||||
// /login?next=/
|
// /login?next=/
|
||||||
// /user/John%20Doe
|
// /user/John%20Doe
|
||||||
//
|
//
|
||||||
// more detail http://beego.me/docs/mvc/controller/urlbuilding.md
|
// more detail http://beego.vip/docs/mvc/controller/urlbuilding.md
|
||||||
func URLFor(endpoint string, values ...interface{}) string {
|
func URLFor(endpoint string, values ...interface{}) string {
|
||||||
return web.URLFor(endpoint, values...)
|
return web.URLFor(endpoint, values...)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
//
|
//
|
||||||
// AddHealthCheck("database",&DatabaseCheck{})
|
// AddHealthCheck("database",&DatabaseCheck{})
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/toolbox.md
|
// more docs: http://beego.vip/docs/module/toolbox.md
|
||||||
package toolbox
|
package toolbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -52,7 +52,7 @@ In your view templates:
|
|||||||
|
|
||||||
See also
|
See also
|
||||||
|
|
||||||
http://beego.me/docs/mvc/view/page.md
|
http://beego.vip/docs/mvc/view/page.md
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package pagination
|
package pagination
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more info: http://beego.me/docs/mvc/controller/validation.md
|
// more info: http://beego.vip/docs/mvc/controller/validation.md
|
||||||
package validation
|
package validation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
2
client/cache/cache.go
vendored
2
client/cache/cache.go
vendored
@ -28,7 +28,7 @@
|
|||||||
// bm.IsExist("astaxie")
|
// bm.IsExist("astaxie")
|
||||||
// bm.Delete("astaxie")
|
// bm.Delete("astaxie")
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/cache.md
|
// more docs http://beego.vip/docs/module/cache.md
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
2
client/cache/memcache/memcache.go
vendored
2
client/cache/memcache/memcache.go
vendored
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/cache.md
|
// more docs http://beego.vip/docs/module/cache.md
|
||||||
package memcache
|
package memcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
2
client/cache/redis/redis.go
vendored
2
client/cache/redis/redis.go
vendored
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
// bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/cache.md
|
// more docs http://beego.vip/docs/module/cache.md
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -10,7 +10,7 @@ you can use Get to crawl data.
|
|||||||
|
|
||||||
import "github.com/beego/beego/v2/client/httplib"
|
import "github.com/beego/beego/v2/client/httplib"
|
||||||
|
|
||||||
str, err := httplib.Get("http://beego.me/").String()
|
str, err := httplib.Get("http://beego.vip/").String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ you can use Get to crawl data.
|
|||||||
|
|
||||||
POST data to remote url
|
POST data to remote url
|
||||||
|
|
||||||
req := httplib.Post("http://beego.me/")
|
req := httplib.Post("http://beego.vip/")
|
||||||
req.Param("username","astaxie")
|
req.Param("username","astaxie")
|
||||||
req.Param("password","123456")
|
req.Param("password","123456")
|
||||||
str, err := req.String()
|
str, err := req.String()
|
||||||
@ -38,20 +38,20 @@ The default timeout is `60` seconds, function prototype:
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
httplib.Get("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second)
|
httplib.Get("http://beego.vip/").SetTimeout(100 * time.Second, 30 * time.Second)
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
httplib.Post("http://beego.me/").SetTimeout(100 * time.Second, 30 * time.Second)
|
httplib.Post("http://beego.vip/").SetTimeout(100 * time.Second, 30 * time.Second)
|
||||||
|
|
||||||
## Debug
|
## Debug
|
||||||
|
|
||||||
If you want to debug the request info, set the debug on
|
If you want to debug the request info, set the debug on
|
||||||
|
|
||||||
httplib.Get("http://beego.me/").Debug(true)
|
httplib.Get("http://beego.vip/").Debug(true)
|
||||||
|
|
||||||
## Set HTTP Basic Auth
|
## Set HTTP Basic Auth
|
||||||
|
|
||||||
str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String()
|
str, err := Get("http://beego.vip/").SetBasicAuth("user", "passwd").String()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ More info about the `tls.Config` please visit http://golang.org/pkg/crypto/tls/#
|
|||||||
|
|
||||||
some servers need to specify the protocol version of HTTP
|
some servers need to specify the protocol version of HTTP
|
||||||
|
|
||||||
httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1")
|
httplib.Get("http://beego.vip/").SetProtocolVersion("HTTP/1.1")
|
||||||
|
|
||||||
## Set Cookie
|
## Set Cookie
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ some http request need setcookie. So set it like this:
|
|||||||
cookie := &http.Cookie{}
|
cookie := &http.Cookie{}
|
||||||
cookie.Name = "username"
|
cookie.Name = "username"
|
||||||
cookie.Value = "astaxie"
|
cookie.Value = "astaxie"
|
||||||
httplib.Get("http://beego.me/").SetCookie(cookie)
|
httplib.Get("http://beego.vip/").SetCookie(cookie)
|
||||||
|
|
||||||
## Upload file
|
## Upload file
|
||||||
|
|
||||||
httplib support mutil file upload, use `req.PostFile()`
|
httplib support mutil file upload, use `req.PostFile()`
|
||||||
|
|
||||||
req := httplib.Post("http://beego.me/")
|
req := httplib.Post("http://beego.vip/")
|
||||||
req.Param("username","astaxie")
|
req.Param("username","astaxie")
|
||||||
req.PostFile("uploadfile1", "httplib.pdf")
|
req.PostFile("uploadfile1", "httplib.pdf")
|
||||||
str, err := req.String()
|
str, err := req.String()
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNewClient(t *testing.T) {
|
func TestNewClient(t *testing.T) {
|
||||||
client, err := NewClient("test1", "http://beego.me", WithEnableCookie(true))
|
client, err := NewClient("test1", "http://beego.vip", WithEnableCookie(true))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, client)
|
assert.NotNil(t, client)
|
||||||
assert.Equal(t, true, client.Setting.EnableCookie)
|
assert.Equal(t, true, client.Setting.EnableCookie)
|
||||||
@ -204,7 +204,7 @@ func TestClientDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestClientHead(t *testing.T) {
|
func TestClientHead(t *testing.T) {
|
||||||
client, err := NewClient("test", "http://beego.me")
|
client, err := NewClient("test", "http://beego.vip")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
//
|
//
|
||||||
// import "github.com/beego/beego/v2/client/httplib"
|
// import "github.com/beego/beego/v2/client/httplib"
|
||||||
//
|
//
|
||||||
// b := httplib.Post("http://beego.me/")
|
// b := httplib.Post("http://beego.vip/")
|
||||||
// b.Param("username","astaxie")
|
// b.Param("username","astaxie")
|
||||||
// b.Param("password","123456")
|
// b.Param("password","123456")
|
||||||
// b.PostFile("uploadfile1", "httplib.pdf")
|
// b.PostFile("uploadfile1", "httplib.pdf")
|
||||||
@ -28,7 +28,7 @@
|
|||||||
// }
|
// }
|
||||||
// fmt.Println(str)
|
// fmt.Println(str)
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/httplib.md
|
// more docs http://beego.vip/docs/module/httplib.md
|
||||||
package httplib
|
package httplib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -290,19 +290,19 @@ func TestHeader(t *testing.T) {
|
|||||||
|
|
||||||
// TestAddFilter make sure that AddFilters only work for the specific request
|
// TestAddFilter make sure that AddFilters only work for the specific request
|
||||||
func TestAddFilter(t *testing.T) {
|
func TestAddFilter(t *testing.T) {
|
||||||
req := Get("http://beego.me")
|
req := Get("http://beego.vip")
|
||||||
req.AddFilters(func(next Filter) Filter {
|
req.AddFilters(func(next Filter) Filter {
|
||||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||||
return next(ctx, req)
|
return next(ctx, req)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
r := Get("http://beego.me")
|
r := Get("http://beego.vip")
|
||||||
assert.Equal(t, 1, len(req.setting.FilterChains)-len(r.setting.FilterChains))
|
assert.Equal(t, 1, len(req.setting.FilterChains)-len(r.setting.FilterChains))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterChainOrder(t *testing.T) {
|
func TestFilterChainOrder(t *testing.T) {
|
||||||
req := Get("http://beego.me")
|
req := Get("http://beego.vip")
|
||||||
req.AddFilters(func(next Filter) Filter {
|
req.AddFilters(func(next Filter) Filter {
|
||||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||||
return NewHttpResponseWithJsonBody("first"), nil
|
return NewHttpResponseWithJsonBody("first"), nil
|
||||||
@ -323,35 +323,35 @@ func TestFilterChainOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHead(t *testing.T) {
|
func TestHead(t *testing.T) {
|
||||||
req := Head("http://beego.me")
|
req := Head("http://beego.vip")
|
||||||
assert.NotNil(t, req)
|
assert.NotNil(t, req)
|
||||||
assert.Equal(t, "HEAD", req.req.Method)
|
assert.Equal(t, "HEAD", req.req.Method)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDelete(t *testing.T) {
|
func TestDelete(t *testing.T) {
|
||||||
req := Delete("http://beego.me")
|
req := Delete("http://beego.vip")
|
||||||
assert.NotNil(t, req)
|
assert.NotNil(t, req)
|
||||||
assert.Equal(t, "DELETE", req.req.Method)
|
assert.Equal(t, "DELETE", req.req.Method)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPost(t *testing.T) {
|
func TestPost(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
assert.NotNil(t, req)
|
assert.NotNil(t, req)
|
||||||
assert.Equal(t, "POST", req.req.Method)
|
assert.Equal(t, "POST", req.req.Method)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNewBeegoRequest(t *testing.T) {
|
func TestNewBeegoRequest(t *testing.T) {
|
||||||
req := NewBeegoRequest("http://beego.me", "GET")
|
req := NewBeegoRequest("http://beego.vip", "GET")
|
||||||
assert.NotNil(t, req)
|
assert.NotNil(t, req)
|
||||||
assert.Equal(t, "GET", req.req.Method)
|
assert.Equal(t, "GET", req.req.Method)
|
||||||
|
|
||||||
// invalid case but still go request
|
// invalid case but still go request
|
||||||
req = NewBeegoRequest("httpa\ta://beego.me", "GET")
|
req = NewBeegoRequest("httpa\ta://beego.vip", "GET")
|
||||||
assert.NotNil(t, req)
|
assert.NotNil(t, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestSetProtocolVersion(t *testing.T) {
|
func TestBeegoHTTPRequestSetProtocolVersion(t *testing.T) {
|
||||||
req := NewBeegoRequest("http://beego.me", "GET")
|
req := NewBeegoRequest("http://beego.vip", "GET")
|
||||||
req.SetProtocolVersion("HTTP/3.10")
|
req.SetProtocolVersion("HTTP/3.10")
|
||||||
assert.Equal(t, "HTTP/3.10", req.req.Proto)
|
assert.Equal(t, "HTTP/3.10", req.req.Proto)
|
||||||
assert.Equal(t, 3, req.req.ProtoMajor)
|
assert.Equal(t, 3, req.req.ProtoMajor)
|
||||||
@ -370,27 +370,27 @@ func TestBeegoHTTPRequestSetProtocolVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPut(t *testing.T) {
|
func TestPut(t *testing.T) {
|
||||||
req := Put("http://beego.me")
|
req := Put("http://beego.vip")
|
||||||
assert.NotNil(t, req)
|
assert.NotNil(t, req)
|
||||||
assert.Equal(t, "PUT", req.req.Method)
|
assert.Equal(t, "PUT", req.req.Method)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestHeader(t *testing.T) {
|
func TestBeegoHTTPRequestHeader(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
key, value := "test-header", "test-header-value"
|
key, value := "test-header", "test-header-value"
|
||||||
req.Header(key, value)
|
req.Header(key, value)
|
||||||
assert.Equal(t, value, req.req.Header.Get(key))
|
assert.Equal(t, value, req.req.Header.Get(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestSetHost(t *testing.T) {
|
func TestBeegoHTTPRequestSetHost(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
host := "test-hose"
|
host := "test-hose"
|
||||||
req.SetHost(host)
|
req.SetHost(host)
|
||||||
assert.Equal(t, host, req.req.Host)
|
assert.Equal(t, host, req.req.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestParam(t *testing.T) {
|
func TestBeegoHTTPRequestParam(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
key, value := "test-param", "test-param-value"
|
key, value := "test-param", "test-param-value"
|
||||||
req.Param(key, value)
|
req.Param(key, value)
|
||||||
assert.Equal(t, value, req.params[key][0])
|
assert.Equal(t, value, req.params[key][0])
|
||||||
@ -401,7 +401,7 @@ func TestBeegoHTTPRequestParam(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestBody(t *testing.T) {
|
func TestBeegoHTTPRequestBody(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
body := `hello, world`
|
body := `hello, world`
|
||||||
req.Body([]byte(body))
|
req.Body([]byte(body))
|
||||||
assert.Equal(t, int64(len(body)), req.req.ContentLength)
|
assert.Equal(t, int64(len(body)), req.req.ContentLength)
|
||||||
@ -423,7 +423,7 @@ type user struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestXMLBody(t *testing.T) {
|
func TestBeegoHTTPRequestXMLBody(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
body := &user{
|
body := &user{
|
||||||
Name: "Tom",
|
Name: "Tom",
|
||||||
}
|
}
|
||||||
@ -438,7 +438,7 @@ func TestBeegoHTTPRequestResponseForValue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBeegoHTTPRequestJSONMarshal(t *testing.T) {
|
func TestBeegoHTTPRequestJSONMarshal(t *testing.T) {
|
||||||
req := Post("http://beego.me")
|
req := Post("http://beego.vip")
|
||||||
req.SetEscapeHTML(false)
|
req.SetEscapeHTML(false)
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"escape": "left&right",
|
"escape": "left&right",
|
||||||
|
|||||||
@ -155,5 +155,5 @@ note: not recommend use this in product env.
|
|||||||
|
|
||||||
more details and examples in docs and test
|
more details and examples in docs and test
|
||||||
|
|
||||||
[documents](http://beego.me/docs/mvc/model/overview.md)
|
[documents](http://beego.vip/docs/mvc/model/overview.md)
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
// num, err = o.Delete(&u)
|
// num, err = o.Delete(&u)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/mvc/model/overview.md
|
// more docs: http://beego.vip/docs/mvc/model/overview.md
|
||||||
package orm
|
package orm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -27,7 +27,7 @@
|
|||||||
//
|
//
|
||||||
// AddHealthCheck("database",&DatabaseCheck{})
|
// AddHealthCheck("database",&DatabaseCheck{})
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/toolbox.md
|
// more docs: http://beego.vip/docs/module/toolbox.md
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
// AdminCheckList holds health checker map
|
// AdminCheckList holds health checker map
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
// cnf.DIY(key string) (interface{}, error)
|
// cnf.DIY(key string) (interface{}, error)
|
||||||
// cnf.GetSection(section string) (map[string]string, error)
|
// cnf.GetSection(section string) (map[string]string, error)
|
||||||
// cnf.SaveConfigFile(filename string) error
|
// cnf.SaveConfigFile(filename string) error
|
||||||
// More docs http://beego.me/docs/module/config.md
|
// More docs http://beego.vip/docs/module/config.md
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("xml", "config.xml")
|
// cnf, err := config.NewConfig("xml", "config.xml")
|
||||||
//
|
//
|
||||||
// More docs http://beego.me/docs/module/config.md
|
// More docs http://beego.vip/docs/module/config.md
|
||||||
package xml
|
package xml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
//
|
//
|
||||||
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
// cnf, err := config.NewConfig("yaml", "config.yaml")
|
||||||
//
|
//
|
||||||
// More docs http://beego.me/docs/module/config.md
|
// More docs http://beego.vip/docs/module/config.md
|
||||||
package yaml
|
package yaml
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
// log.Debug("debug")
|
// log.Debug("debug")
|
||||||
// log.Critical("critical")
|
// log.Critical("critical")
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/logs.md
|
// more docs http://beego.vip/docs/module/logs.md
|
||||||
package logs
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -52,7 +52,7 @@ In your view templates:
|
|||||||
|
|
||||||
See also
|
See also
|
||||||
|
|
||||||
http://beego.me/docs/mvc/view/page.md
|
http://beego.vip/docs/mvc/view/page.md
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package pagination
|
package pagination
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more info: http://beego.me/docs/mvc/controller/validation.md
|
// more info: http://beego.vip/docs/mvc/controller/validation.md
|
||||||
package validation
|
package validation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -21,10 +21,10 @@ var indexTpl = `
|
|||||||
For detail usage please check our document:
|
For detail usage please check our document:
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a target="_blank" href="http://beego.me/docs/module/admin.md">Toolbox</a>
|
<a target="_blank" href="http://beego.vip/docs/module/admin.md">Toolbox</a>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a target="_blank" href="http://beego.me/docs/advantage/monitor.md">Live Monitor</a>
|
<a target="_blank" href="http://beego.vip/docs/advantage/monitor.md">Live Monitor</a>
|
||||||
</p>
|
</p>
|
||||||
{{.Content}}
|
{{.Content}}
|
||||||
{{end}}`
|
{{end}}`
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
//
|
//
|
||||||
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
// ctx := context.Context{Request:req,ResponseWriter:rw}
|
||||||
//
|
//
|
||||||
// more docs http://beego.me/docs/module/context.md
|
// more docs http://beego.vip/docs/module/context.md
|
||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -12,6 +12,6 @@ beego is inspired by Tornado, Sinatra and Flask with the added benefit of some G
|
|||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
more information: http://beego.me
|
more information: http://beego.vip
|
||||||
*/
|
*/
|
||||||
package web
|
package web
|
||||||
|
|||||||
@ -48,7 +48,7 @@ func NewNamespace(prefix string, params ...LinkNamespace) *Namespace {
|
|||||||
// if cond return true can run this namespace, else can't
|
// if cond return true can run this namespace, else can't
|
||||||
// usage:
|
// usage:
|
||||||
// ns.Cond(func (ctx *context.Context) bool{
|
// ns.Cond(func (ctx *context.Context) bool{
|
||||||
// if ctx.Input.Domain() == "api.beego.me" {
|
// if ctx.Input.Domain() == "api.beego.vip" {
|
||||||
// return true
|
// return true
|
||||||
// }
|
// }
|
||||||
// return false
|
// return false
|
||||||
|
|||||||
@ -174,7 +174,7 @@ func TestNamespaceCond(t *testing.T) {
|
|||||||
|
|
||||||
ns := NewNamespace("/v2")
|
ns := NewNamespace("/v2")
|
||||||
ns.Cond(func(ctx *context.Context) bool {
|
ns.Cond(func(ctx *context.Context) bool {
|
||||||
return ctx.Input.Domain() == "beego.me"
|
return ctx.Input.Domain() == "beego.vip"
|
||||||
}).
|
}).
|
||||||
AutoRouter(&TestController{})
|
AutoRouter(&TestController{})
|
||||||
AddNamespace(ns)
|
AddNamespace(ns)
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package couchbase
|
package couchbase
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package memcache
|
package memcache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package mysql
|
package mysql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -47,7 +47,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package postgres
|
package postgres
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package redis_cluster
|
package redis_cluster
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
// go globalSessions.GC()
|
// go globalSessions.GC()
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// more docs: http://beego.me/docs/module/session.md
|
// more docs: http://beego.vip/docs/module/session.md
|
||||||
package session
|
package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@ -242,7 +242,7 @@ func Htmlunquote(text string) string {
|
|||||||
// /login?next=/
|
// /login?next=/
|
||||||
// /user/John%20Doe
|
// /user/John%20Doe
|
||||||
//
|
//
|
||||||
// more detail http://beego.me/docs/mvc/controller/urlbuilding.md
|
// more detail http://beego.vip/docs/mvc/controller/urlbuilding.md
|
||||||
func URLFor(endpoint string, values ...interface{}) string {
|
func URLFor(endpoint string, values ...interface{}) string {
|
||||||
return BeeApp.Handlers.URLFor(endpoint, values...)
|
return BeeApp.Handlers.URLFor(endpoint, values...)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user