go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/r2/opt_method.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package r2 9 10 import "net/http" 11 12 // OptMethod sets the request method. 13 func OptMethod(method string) Option { 14 return func(r *Request) error { 15 r.req.Method = method 16 return nil 17 } 18 } 19 20 // OptGet sets the request method. 21 func OptGet() Option { 22 return func(r *Request) error { 23 r.req.Method = http.MethodGet 24 return nil 25 } 26 } 27 28 // OptPost sets the request method. 29 func OptPost() Option { 30 return func(r *Request) error { 31 r.req.Method = http.MethodPost 32 return nil 33 } 34 } 35 36 // OptPut sets the request method. 37 func OptPut() Option { 38 return func(r *Request) error { 39 r.req.Method = http.MethodPut 40 return nil 41 } 42 } 43 44 // OptPatch sets the request method. 45 func OptPatch() Option { 46 return func(r *Request) error { 47 r.req.Method = http.MethodPatch 48 return nil 49 } 50 } 51 52 // OptDelete sets the request method. 53 func OptDelete() Option { 54 return func(r *Request) error { 55 r.req.Method = http.MethodDelete 56 return nil 57 } 58 } 59 60 // OptOptions sets the request method. 61 func OptOptions() Option { 62 return func(r *Request) error { 63 r.req.Method = http.MethodOptions 64 return nil 65 } 66 }