-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ekomobile/errors
Wrap errors. Added ResponseError. Abstract transport encoding/decoding.
- Loading branch information
Showing
6 changed files
with
195 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package client | ||
|
||
import "fmt" | ||
|
||
// ResponseError indicates an HTTP non-200 response code. | ||
type ResponseError struct { | ||
Status string // e.g. "200 OK" | ||
StatusCode int // e.g. 200 | ||
} | ||
|
||
func (e *ResponseError) Error() string { | ||
return fmt.Sprintf("HTTP response: %s", e.Status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package transport | ||
|
||
import "io" | ||
|
||
type ( | ||
// EncoderFactory creates new request encoder | ||
EncoderFactory func(w io.Writer) Encoder | ||
|
||
// DecoderFactory creates new response decoder | ||
DecoderFactory func(r io.Reader) Decoder | ||
|
||
// Encoder encodes request from v | ||
Encoder func(v interface{}) error | ||
|
||
// Decoder decodes response into v. | ||
Decoder func(v interface{}) error | ||
) |