eaffabf3 by fanngyuan

add client

1 parent 0b74db64
1 package testing
2
3 import (
4 "github.com/fanngyuan/beego"
5 "github.com/fanngyuan/beego/httplib"
6 // "strings"
7 // "fmt"
8 )
9
10 var port = ""
11 var baseUrl = "http://localhost:"
12
13 type TestHttpRequest struct{
14 httplib.BeegoHttpRequest
15 }
16
17 func getPort() string{
18 if port==""{
19 config,err:= beego.LoadConfig("../conf/app.conf")
20 if err!=nil{
21 return "8080"
22 }
23 port=config.String("httpport")
24 return port
25 }
26 return port
27 }
28
29 func Get(path string) *TestHttpRequest {
30 return &TestHttpRequest{*httplib.Get(baseUrl+getPort()+path)}
31 }
32
33 func Post(path string) *TestHttpRequest {
34 return &TestHttpRequest{*httplib.Post(baseUrl+getPort()+path)}
35 }
36
37 func Put(path string) *TestHttpRequest {
38 return &TestHttpRequest{*httplib.Put(baseUrl+getPort()+path)}
39 }
40
41 func Delete(path string) *TestHttpRequest {
42 return &TestHttpRequest{*httplib.Delete(baseUrl+getPort()+path)}
43 }
44
45 func Head(path string) *TestHttpRequest {
46 return &TestHttpRequest{*httplib.Head(baseUrl+getPort()+path)}
47 }
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!