Documentation
¶
Overview ¶
package trip implements a round-trip pattern for http requests
Index ¶
Constants ¶
View Source
const BadResponse = 590
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
Client Client
Request *http.Request
Response *http.Response
// IsOk should return false if the response is considered wrong, according
// to status and headers. The body should not be parsed.
IsOk func(*http.Response) bool
// Parse should convert the response into the given model. By default json.Unmarshal is
// used. Parse should close the reader when done or on error.
Parse func(io.ReadCloser, interface{}) error
// Duration to wait before next retry
Pause time.Duration
// contains filtered or unexported fields
}
func NewCommand ¶
NewCommand returns a command using the http.DefaultClient. By default requests that have a status code larger or equal to 400 return an error
func (*Command) Dump ¶
Dump writes request and response information, if body has already been read body=true has no affect.
func (*Command) Output ¶
Output sends the request and does a status validation against considered status codes. Failing to send the request altogether results in a 590. Parsing errors result in 591
Click to show internal directories.
Click to hide internal directories.