1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 05:21:30 +00:00
This commit is contained in:
jessonchan 2014-08-22 16:43:42 +08:00
parent 01e4084587
commit 7b39bd7042

View File

@ -73,49 +73,42 @@ func SetDefaultSetting(setting BeegoHttpSettings) {
} }
} }
// Get returns *BeegoHttpRequest with GET method. // return *BeegoHttpRequest with specific method
func Get(url string) *BeegoHttpRequest { func newBeegoRequest(url, method string) *BeegoHttpRequest {
var req http.Request req := http.Request{
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
}
var resp http.Response var resp http.Response
req.Method = "GET" req.Method = method
req.Header = http.Header{} req.Header = http.Header{}
return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil} return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil}
} }
// Get returns *BeegoHttpRequest with GET method.
func Get(url string) *BeegoHttpRequest {
return newBeegoRequest(url, "GET")
}
// Post returns *BeegoHttpRequest with POST method. // Post returns *BeegoHttpRequest with POST method.
func Post(url string) *BeegoHttpRequest { func Post(url string) *BeegoHttpRequest {
var req http.Request return newBeegoRequest(url, "POST")
var resp http.Response
req.Method = "POST"
req.Header = http.Header{}
return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil}
} }
// Put returns *BeegoHttpRequest with PUT method. // Put returns *BeegoHttpRequest with PUT method.
func Put(url string) *BeegoHttpRequest { func Put(url string) *BeegoHttpRequest {
var req http.Request return newBeegoRequest(url, "PUT")
var resp http.Response
req.Method = "PUT"
req.Header = http.Header{}
return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil}
} }
// Delete returns *BeegoHttpRequest DELETE GET method. // Delete returns *BeegoHttpRequest DELETE GET method.
func Delete(url string) *BeegoHttpRequest { func Delete(url string) *BeegoHttpRequest {
var req http.Request return newBeegoRequest(url, "DELETE")
var resp http.Response
req.Method = "DELETE"
req.Header = http.Header{}
return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil}
} }
// Head returns *BeegoHttpRequest with HEAD method. // Head returns *BeegoHttpRequest with HEAD method.
func Head(url string) *BeegoHttpRequest { func Head(url string) *BeegoHttpRequest {
var req http.Request return newBeegoRequest(url, "HEAD")
var resp http.Response
req.Method = "HEAD"
req.Header = http.Header{}
return &BeegoHttpRequest{url, &req, map[string]string{}, map[string]string{}, defaultSetting, &resp, nil}
} }
// BeegoHttpSettings // BeegoHttpSettings