-
Notifications
You must be signed in to change notification settings - Fork 2
/
maker.go
52 lines (41 loc) · 1.05 KB
/
maker.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
45
46
47
48
49
50
51
52
package fakepoint
import (
"net/http"
)
func NewFakepointMaker() *FakepointMaker {
agent := NewAgent()
maker := &FakepointMaker{
agent: agent,
}
agent.maker = maker
return maker
}
type FakepointMaker struct {
agent *Agent
}
func (f FakepointMaker) Client() *http.Client {
return &http.Client{ Transport: f.agent }
}
func (f FakepointMaker) AddTrip(method, url string, statusCode int) *Fakepoint {
fr := &Fakepoint{
method: method,
url: url,
statusCode: statusCode,
header: &http.Header{},
agent: f.agent,
}
f.agent.add(url, method, fr)
return fr
}
func (f FakepointMaker) NewGet(url string, statusCode int) *Fakepoint {
return f.AddTrip("GET", url, statusCode)
}
func (f FakepointMaker) NewPost(url string, statusCode int) *Fakepoint {
return f.AddTrip("POST", url, statusCode)
}
func (f FakepointMaker) NewPut(url string, statusCode int) *Fakepoint {
return f.AddTrip("PUT", url, statusCode)
}
func (f FakepointMaker) NewDelete(url string, statusCode int) *Fakepoint {
return f.AddTrip("DELETE", url, statusCode)
}