mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
add convenience function g.Client for ghttp.Client
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "github.com/gogf/gf/os/gres/testdata/example/boot"
|
||||
|
||||
"github.com/gogf/gf/frame/g"
|
||||
"github.com/gogf/gf/net/ghttp"
|
||||
_ "github.com/gogf/gf/os/gres/testdata/example/boot"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@ -1263,6 +1263,18 @@ func Test_Model_Where_ISNULL_2(t *testing.T) {
|
||||
t.Assert(result[0]["id"].Int(), 1)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_Where_GTime(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
result, err := db.Table(table).Where("create_time>?", gtime.NewFromStr("2010-09-01")).All()
|
||||
t.Assert(err, nil)
|
||||
t.Assert(len(result), 10)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Model_WherePri(t *testing.T) {
|
||||
table := createInitTable()
|
||||
defer dropTable(table)
|
||||
|
||||
@ -20,6 +20,11 @@ import (
|
||||
"github.com/gogf/gf/os/gview"
|
||||
)
|
||||
|
||||
// Client is a convenience function, that creates and returns a new HTTP client.
|
||||
func Client() *ghttp.Client {
|
||||
return ghttp.NewClient()
|
||||
}
|
||||
|
||||
// Server returns an instance of http server with specified name.
|
||||
func Server(name ...interface{}) *ghttp.Server {
|
||||
return gins.Server(name...)
|
||||
|
||||
@ -36,7 +36,7 @@ func NewClient() *Client {
|
||||
return &Client{
|
||||
Client: http.Client{
|
||||
Transport: &http.Transport{
|
||||
// No validation for https certification of the server.
|
||||
// No validation for https certification of the server in default.
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/encoding/gparser"
|
||||
"github.com/gogf/gf/text/gregex"
|
||||
"github.com/gogf/gf/text/gstr"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
@ -88,7 +89,7 @@ func (c *Client) Trace(url string, data ...interface{}) (*ClientResponse, error)
|
||||
func (c *Client) DoRequest(method, url string, data ...interface{}) (resp *ClientResponse, err error) {
|
||||
method = strings.ToUpper(method)
|
||||
if len(c.prefix) > 0 {
|
||||
url = c.prefix + url
|
||||
url = c.prefix + gstr.Trim(url)
|
||||
}
|
||||
param := ""
|
||||
if len(data) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user