From 2c6b9f8263d9a2455082d0c7130d75e03f9f157b Mon Sep 17 00:00:00 2001 From: Aras Azimipanah Date: Fri, 8 Nov 2019 08:55:15 -0500 Subject: [PATCH] Add HTTP Options request to the client. --- client.go | 7 +++++++ client_test.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/client.go b/client.go index ef7d9eb..6d95e55 100644 --- a/client.go +++ b/client.go @@ -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() diff --git a/client_test.go b/client_test.go index a8bc7d6..6a05953 100644 --- a/client_test.go +++ b/client_test.go @@ -281,4 +281,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) + } }