Skip to content

Commit

Permalink
Merge pull request #49 from ArasAzimi/options-req
Browse files Browse the repository at this point in the history
Add HTTP Options request to the client.
  • Loading branch information
h2non committed Feb 17, 2020
2 parents 8bf8c8b + 2c6b9f8 commit df41097
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client.go
Expand Up @@ -49,6 +49,13 @@ func (c *Client) Request() *Request {
return req
}

// Options creates a new OPTIONS request.
func (c *Client) Options() *Request {
req := c.Request()
req.Method("OPTIONS")
return req
}

// Get creates a new GET request.
func (c *Client) Get() *Request {
req := c.Request()
Expand Down
7 changes: 7 additions & 0 deletions client_test.go
Expand Up @@ -291,4 +291,11 @@ func TestClientVerbMethods(t *testing.T) {
if req.Context.Request.Method != "HEAD" {
t.Errorf("Invalid request method: %s", req.Context.Request.Method)
}

cli = New()
req = cli.Options()
req.Middleware.Run("request", req.Context)
if req.Context.Request.Method != "OPTIONS" {
t.Errorf("Invalid request method: %s", req.Context.Request.Method)
}
}

0 comments on commit df41097

Please sign in to comment.