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

Commit

Permalink
1.1.0: Adding support for additional HTTP methods
Browse files Browse the repository at this point in the history
This release adds support for the Delete, Put, and Patch methods.
  • Loading branch information
Janos Pasztor committed Apr 26, 2021
1 parent 5f1a873 commit 8b6117d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.0: Adding support for additional HTTP methods

This release adds support for the Delete, Put, and Patch methods.

## 1.0.2: Adding support for www-urlencoded request body

This release adds the ability to switch request bodies to the `www-urlencoded` encoding for the purposes of OAuth2 authentication.
Expand Down
24 changes: 24 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,28 @@ type Client interface {
requestBody interface{},
responseBody interface{},
) (statusCode int, err error)

// Put queries the configured endpoint with the path, sending the requestBody and providing the
// response in the responseBody structure. It returns the HTTP status code and any potential errors.
Put(
path string,
requestBody interface{},
responseBody interface{},
) (statusCode int, err error)

// Patch queries the configured endpoint with the path, sending the requestBody and providing the
// response in the responseBody structure. It returns the HTTP status code and any potential errors.
Patch(
path string,
requestBody interface{},
responseBody interface{},
) (statusCode int, err error)

// Delete queries the configured endpoint with the path, sending the requestBody and providing the
// response in the responseBody structure. It returns the HTTP status code and any potential errors.
Delete(
path string,
requestBody interface{},
responseBody interface{},
) (statusCode int, err error)
}
39 changes: 39 additions & 0 deletions client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,45 @@ type client struct {
tlsConfig *tls.Config
}

func (c *client) Put(
path string,
requestBody interface{},
responseBody interface{},
) (statusCode int, err error) {
return c.request(
http.MethodPut,
path,
requestBody,
responseBody,
)
}

func (c *client) Patch(
path string,
requestBody interface{},
responseBody interface{},
) (statusCode int, err error) {
return c.request(
http.MethodPatch,
path,
requestBody,
responseBody,
)
}

func (c *client) Delete(
path string,
requestBody interface{},
responseBody interface{},
) (statusCode int, err error) {
return c.request(
http.MethodDelete,
path,
requestBody,
responseBody,
)
}

func (c *client) Request(Method string, path string, requestBody interface{}, responseBody interface{}) (statusCode int, err error) {
return c.request(
Method,
Expand Down

0 comments on commit 8b6117d

Please sign in to comment.