replace beego.me with beego.vip
This commit is contained in:
2
client/cache/cache.go
vendored
2
client/cache/cache.go
vendored
@@ -28,7 +28,7 @@
|
||||
// bm.IsExist("astaxie")
|
||||
// bm.Delete("astaxie")
|
||||
//
|
||||
// more docs http://beego.me/docs/module/cache.md
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package cache
|
||||
|
||||
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"}`)
|
||||
//
|
||||
// more docs http://beego.me/docs/module/cache.md
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package memcache
|
||||
|
||||
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"}`)
|
||||
//
|
||||
// more docs http://beego.me/docs/module/cache.md
|
||||
// more docs http://beego.vip/docs/module/cache.md
|
||||
package redis
|
||||
|
||||
import (
|
||||
|
||||
@@ -10,7 +10,7 @@ you can use Get to crawl data.
|
||||
|
||||
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 {
|
||||
// error
|
||||
}
|
||||
@@ -20,7 +20,7 @@ you can use Get to crawl data.
|
||||
|
||||
POST data to remote url
|
||||
|
||||
req := httplib.Post("http://beego.me/")
|
||||
req := httplib.Post("http://beego.vip/")
|
||||
req.Param("username","astaxie")
|
||||
req.Param("password","123456")
|
||||
str, err := req.String()
|
||||
@@ -38,20 +38,20 @@ The default timeout is `60` seconds, function prototype:
|
||||
Example:
|
||||
|
||||
// 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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
str, err := Get("http://beego.me/").SetBasicAuth("user", "passwd").String()
|
||||
str, err := Get("http://beego.vip/").SetBasicAuth("user", "passwd").String()
|
||||
if err != nil {
|
||||
// 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
|
||||
|
||||
httplib.Get("http://beego.me/").SetProtocolVersion("HTTP/1.1")
|
||||
httplib.Get("http://beego.vip/").SetProtocolVersion("HTTP/1.1")
|
||||
|
||||
## Set Cookie
|
||||
|
||||
@@ -78,13 +78,13 @@ some http request need setcookie. So set it like this:
|
||||
cookie := &http.Cookie{}
|
||||
cookie.Name = "username"
|
||||
cookie.Value = "astaxie"
|
||||
httplib.Get("http://beego.me/").SetCookie(cookie)
|
||||
httplib.Get("http://beego.vip/").SetCookie(cookie)
|
||||
|
||||
## Upload file
|
||||
|
||||
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.PostFile("uploadfile1", "httplib.pdf")
|
||||
str, err := req.String()
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
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.NotNil(t, client)
|
||||
assert.Equal(t, true, client.Setting.EnableCookie)
|
||||
@@ -204,7 +204,7 @@ func TestClientDelete(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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//
|
||||
// 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("password","123456")
|
||||
// b.PostFile("uploadfile1", "httplib.pdf")
|
||||
@@ -28,7 +28,7 @@
|
||||
// }
|
||||
// fmt.Println(str)
|
||||
//
|
||||
// more docs http://beego.me/docs/module/httplib.md
|
||||
// more docs http://beego.vip/docs/module/httplib.md
|
||||
package httplib
|
||||
|
||||
import (
|
||||
|
||||
@@ -290,19 +290,19 @@ func TestHeader(t *testing.T) {
|
||||
|
||||
// TestAddFilter make sure that AddFilters only work for the specific request
|
||||
func TestAddFilter(t *testing.T) {
|
||||
req := Get("http://beego.me")
|
||||
req := Get("http://beego.vip")
|
||||
req.AddFilters(func(next Filter) Filter {
|
||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||
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))
|
||||
}
|
||||
|
||||
func TestFilterChainOrder(t *testing.T) {
|
||||
req := Get("http://beego.me")
|
||||
req := Get("http://beego.vip")
|
||||
req.AddFilters(func(next Filter) Filter {
|
||||
return func(ctx context.Context, req *BeegoHTTPRequest) (*http.Response, error) {
|
||||
return NewHttpResponseWithJsonBody("first"), nil
|
||||
@@ -323,35 +323,35 @@ func TestFilterChainOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHead(t *testing.T) {
|
||||
req := Head("http://beego.me")
|
||||
req := Head("http://beego.vip")
|
||||
assert.NotNil(t, req)
|
||||
assert.Equal(t, "HEAD", req.req.Method)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
req := Delete("http://beego.me")
|
||||
req := Delete("http://beego.vip")
|
||||
assert.NotNil(t, req)
|
||||
assert.Equal(t, "DELETE", req.req.Method)
|
||||
}
|
||||
|
||||
func TestPost(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
assert.NotNil(t, req)
|
||||
assert.Equal(t, "POST", req.req.Method)
|
||||
}
|
||||
|
||||
func TestNewBeegoRequest(t *testing.T) {
|
||||
req := NewBeegoRequest("http://beego.me", "GET")
|
||||
req := NewBeegoRequest("http://beego.vip", "GET")
|
||||
assert.NotNil(t, req)
|
||||
assert.Equal(t, "GET", req.req.Method)
|
||||
|
||||
// invalid case but still go request
|
||||
req = NewBeegoRequest("httpa\ta://beego.me", "GET")
|
||||
req = NewBeegoRequest("httpa\ta://beego.vip", "GET")
|
||||
assert.NotNil(t, req)
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestSetProtocolVersion(t *testing.T) {
|
||||
req := NewBeegoRequest("http://beego.me", "GET")
|
||||
req := NewBeegoRequest("http://beego.vip", "GET")
|
||||
req.SetProtocolVersion("HTTP/3.10")
|
||||
assert.Equal(t, "HTTP/3.10", req.req.Proto)
|
||||
assert.Equal(t, 3, req.req.ProtoMajor)
|
||||
@@ -370,27 +370,27 @@ func TestBeegoHTTPRequestSetProtocolVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPut(t *testing.T) {
|
||||
req := Put("http://beego.me")
|
||||
req := Put("http://beego.vip")
|
||||
assert.NotNil(t, req)
|
||||
assert.Equal(t, "PUT", req.req.Method)
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestHeader(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
key, value := "test-header", "test-header-value"
|
||||
req.Header(key, value)
|
||||
assert.Equal(t, value, req.req.Header.Get(key))
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestSetHost(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
host := "test-hose"
|
||||
req.SetHost(host)
|
||||
assert.Equal(t, host, req.req.Host)
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestParam(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
key, value := "test-param", "test-param-value"
|
||||
req.Param(key, value)
|
||||
assert.Equal(t, value, req.params[key][0])
|
||||
@@ -401,7 +401,7 @@ func TestBeegoHTTPRequestParam(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestBody(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
body := `hello, world`
|
||||
req.Body([]byte(body))
|
||||
assert.Equal(t, int64(len(body)), req.req.ContentLength)
|
||||
@@ -423,7 +423,7 @@ type user struct {
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestXMLBody(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
body := &user{
|
||||
Name: "Tom",
|
||||
}
|
||||
@@ -438,7 +438,7 @@ func TestBeegoHTTPRequestResponseForValue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBeegoHTTPRequestJSONMarshal(t *testing.T) {
|
||||
req := Post("http://beego.me")
|
||||
req := Post("http://beego.vip")
|
||||
req.SetEscapeHTML(false)
|
||||
body := map[string]interface{}{
|
||||
"escape": "left&right",
|
||||
|
||||
@@ -155,5 +155,5 @@ note: not recommend use this in product env.
|
||||
|
||||
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)
|
||||
// }
|
||||
//
|
||||
// more docs: http://beego.me/docs/mvc/model/overview.md
|
||||
// more docs: http://beego.vip/docs/mvc/model/overview.md
|
||||
package orm
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user