-
Notifications
You must be signed in to change notification settings - Fork 5
/
session.go
44 lines (34 loc) · 1.31 KB
/
session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package zhttp
import (
"net/http/cookiejar"
)
// Session is a client used to send http requests.
// Unlike Zhttp, it handle session for all requests
type Session struct {
z *Zhttp
CookieJar *cookiejar.Jar
}
func (s *Session) Get(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("GET", url, options, s.CookieJar)
}
func (s *Session) Post(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("POST", url, options, s.CookieJar)
}
func (s *Session) Head(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("HEAD", url, options, s.CookieJar)
}
func (s *Session) Put(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("PUT", url, options, s.CookieJar)
}
func (s *Session) Delete(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("DELETE", url, options, s.CookieJar)
}
func (s *Session) Patch(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("PATCH", url, options, s.CookieJar)
}
func (s *Session) Options(url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest("OPTIONS", url, options, s.CookieJar)
}
func (s *Session) Request(method string, url string, options *ReqOptions) (*Response, error) {
return s.z.doRequest(method, url, options, s.CookieJar)
}