diff --git a/README.md b/README.md index 38f3a04..afb0ffa 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Use `Path` to set or extend the URL for created Requests. Extension means the pa req, err := sling.New().Base("https://example.com/").Path("foo/").Path("bar").Request() ``` -Use `Get`, `Post`, `Put`, `Patch`, `Delete`, or `Head` which are exactly the same as `Path` except they set the HTTP method too. +Use `Get`, `Post`, `Put`, `Patch`, `Delete`, `Head`, `Options`, `Trace`, or `Connect` which are exactly the same as `Path` except they set the HTTP method too. ```go req, err := sling.New().Post("http://upload.com/gophers") diff --git a/sling.go b/sling.go index 6070b78..c75fd67 100644 --- a/sling.go +++ b/sling.go @@ -137,6 +137,24 @@ func (s *Sling) Delete(pathURL string) *Sling { return s.Path(pathURL) } +// Options sets the Sling method to OPTIONS and sets the given pathURL. +func (s *Sling) Options(pathURL string) *Sling { + s.method = "OPTIONS" + return s.Path(pathURL) +} + +// Trace sets the Sling method to TRACE and sets the given pathURL. +func (s *Sling) Trace(pathURL string) *Sling { + s.method = "TRACE" + return s.Path(pathURL) +} + +// Connect sets the Sling method to CONNECT and sets the given pathURL. +func (s *Sling) Connect(pathURL string) *Sling { + s.method = "CONNECT" + return s.Path(pathURL) +} + // Header // Add adds the key, value pair in Headers, appending values for existing keys diff --git a/sling_test.go b/sling_test.go index 9c73cd4..ca80334 100644 --- a/sling_test.go +++ b/sling_test.go @@ -196,6 +196,9 @@ func TestMethodSetters(t *testing.T) { {New().Put("http://a.io"), "PUT"}, {New().Patch("http://a.io"), "PATCH"}, {New().Delete("http://a.io"), "DELETE"}, + {New().Options("http://a.io"), "OPTIONS"}, + {New().Trace("http://a.io"), "TRACE"}, + {New().Connect("http://a.io"), "CONNECT"}, } for _, c := range cases { if c.sling.method != c.expectedMethod {