Skip to content

Commit 8a67746

Browse files
committed
codersdk: Create requestOption type
1 parent 61410a5 commit 8a67746

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

codersdk/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ type Client struct {
3333
URL *url.URL
3434
}
3535

36+
type requestOption func(*http.Request)
37+
3638
// request performs an HTTP request with the body provided.
3739
// The caller is responsible for closing the response body.
38-
func (c *Client) request(ctx context.Context, method, path string, body interface{}, opts ...func(r *http.Request)) (*http.Response, error) {
40+
func (c *Client) request(ctx context.Context, method, path string, body interface{}, opts ...requestOption) (*http.Response, error) {
3941
serverURL, err := c.URL.Parse(path)
4042
if err != nil {
4143
return nil, xerrors.Errorf("parse url: %w", err)

codersdk/pagination.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Pagination struct {
2828

2929
// asRequestOption returns a function that can be used in (*Client).request.
3030
// It modifies the request query parameters.
31-
func (p Pagination) asRequestOption() func(*http.Request) {
31+
func (p Pagination) asRequestOption() requestOption {
3232
return func(r *http.Request) {
3333
q := r.URL.Query()
3434
if p.AfterID != uuid.Nil {

0 commit comments

Comments
 (0)