123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package napping
- import (
- "bytes"
- "encoding/json"
- "net/http"
- "net/url"
- "strings"
- "time"
- )
- type Params map[string]string
- func (p Params) AsUrlValues() url.Values {
- result := url.Values{}
- for key, value := range p {
- result.Set(key, value)
- }
- return result
- }
- type Request struct {
- Url string
- Method string
- Params *url.Values
- Payload interface{}
-
-
- RawPayload bool
-
-
- Result interface{}
-
- CaptureResponseBody bool
-
- ResponseBody *bytes.Buffer
-
-
- Error interface{}
-
- Userinfo *url.Userinfo
- Header *http.Header
-
- Transport *http.Transport
-
- timestamp time.Time
- status int
- response *http.Response
- body []byte
- }
- type Response Request
- func (r *Response) Timestamp() time.Time {
- return r.timestamp
- }
- func (r *Response) RawText() string {
- return strings.TrimSpace(string(r.body))
- }
- func (r *Response) Status() int {
- return r.status
- }
- func (r *Response) HttpResponse() *http.Response {
- return r.response
- }
- func (r *Response) Unmarshal(v interface{}) error {
- return json.Unmarshal(r.body, v)
- }
|