Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #29 from engvik/feature/mailbox
Browse files Browse the repository at this point in the history
feature: implement mailbox api
  • Loading branch information
engvik authored Jan 18, 2022
2 parents 4d2661c + 5eb7b83 commit 855f421
Show file tree
Hide file tree
Showing 5 changed files with 1,195 additions and 20 deletions.
7 changes: 7 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ func getTestError(str string) *Error {
}
}

func getTestBasicError(str string) *Error {
return &Error{
StatusCode: 500,
ErrorString: str,
}
}

func TestError(t *testing.T) {
tests := []struct {
name string
Expand Down
12 changes: 11 additions & 1 deletion internal/transport/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type HTTPRequest struct {
Method string
URL string
PostPayload []byte
PutPayload []byte
}

// HTTPResponse represents a http response.
Expand All @@ -36,8 +37,17 @@ func (c *Client) Request(ctx context.Context, r *HTTPRequest) ([]byte, int, erro
var req *http.Request

switch r.Method {
case http.MethodGet:
case http.MethodGet,
http.MethodDelete:
req, err = http.NewRequest(r.Method, r.URL, nil)

case http.MethodPut:
if r.PutPayload == nil {
req, err = http.NewRequest(r.Method, r.URL, nil)
} else {
req, err = http.NewRequest(r.Method, r.URL, bytes.NewBuffer(r.PutPayload))
req.Header.Set("Content-Type", "application/json")
}
case http.MethodPost:
if r.PostPayload == nil {
return nil, 0, errors.New("Post payload missing from POST")
Expand Down
Loading

0 comments on commit 855f421

Please sign in to comment.