Skip to content

Commit

Permalink
Remove SetUnknownResultHandlerFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Jan 24, 2023
1 parent f0e2325 commit f5594c5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 56 deletions.
48 changes: 20 additions & 28 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,26 @@ type Client struct {
DebugLog bool
AllowGetMethodPayload bool

trace bool
disableAutoReadResponse bool
commonErrorType reflect.Type
retryOption *retryOption
jsonMarshal func(v interface{}) ([]byte, error)
jsonUnmarshal func(data []byte, v interface{}) error
xmlMarshal func(v interface{}) ([]byte, error)
xmlUnmarshal func(data []byte, v interface{}) error
outputDirectory string
scheme string
log Logger
t *Transport
dumpOptions *DumpOptions
httpClient *http.Client
beforeRequest []RequestMiddleware
udBeforeRequest []RequestMiddleware
afterResponse []ResponseMiddleware
wrappedRoundTrip RoundTripper
responseBodyTransformer func(rawBody []byte, req *Request, resp *Response) (transformedBody []byte, err error)
unknownResultHandlerFunc func(resp *Response) error
resultStateCheckFunc func(resp *Response) ResultState
trace bool
disableAutoReadResponse bool
commonErrorType reflect.Type
retryOption *retryOption
jsonMarshal func(v interface{}) ([]byte, error)
jsonUnmarshal func(data []byte, v interface{}) error
xmlMarshal func(v interface{}) ([]byte, error)
xmlUnmarshal func(data []byte, v interface{}) error
outputDirectory string
scheme string
log Logger
t *Transport
dumpOptions *DumpOptions
httpClient *http.Client
beforeRequest []RequestMiddleware
udBeforeRequest []RequestMiddleware
afterResponse []ResponseMiddleware
wrappedRoundTrip RoundTripper
responseBodyTransformer func(rawBody []byte, req *Request, resp *Response) (transformedBody []byte, err error)
resultStateCheckFunc func(resp *Response) ResultState
}

// R create a new request.
Expand Down Expand Up @@ -182,13 +181,6 @@ func (c *Client) SetCommonErrorResult(err interface{}) *Client {
return c
}

// SetCommonUnknownResultHandlerFunc set the response handler which will be executed when no
// error occurs, but Response.ResultState returns UnknownState.
func (c *Client) SetCommonUnknownResultHandlerFunc(fn func(resp *Response) error) *Client {
c.unknownResultHandlerFunc = fn
return c
}

// ResultState represents the state of the result.
type ResultState int

Expand Down
6 changes: 0 additions & 6 deletions client_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ func SetCommonErrorResult(err interface{}) *Client {
return defaultClient.SetCommonErrorResult(err)
}

// SetCommonUnknownResultHandlerFunc is a global wrapper methods which delegated
// to the default client's SetCommonUnknownResultHandlerFunc.
func SetCommonUnknownResultHandlerFunc(fn func(resp *Response) error) *Client {
return defaultClient.SetCommonUnknownResultHandlerFunc(fn)
}

// SetResultStateCheckFunc is a global wrapper methods which delegated
// to the default client's SetCommonResultStateCheckFunc.
func SetResultStateCheckFunc(fn func(resp *Response) ResultState) *Client {
Expand Down
8 changes: 0 additions & 8 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,6 @@ func parseResponseBody(c *Client, r *Response) (err error) {
r.error = e
}
}
default:
handleUnknownResult := req.unknownResultHandlerFunc
if handleUnknownResult == nil {
handleUnknownResult = c.unknownResultHandlerFunc
}
if handleUnknownResult != nil {
return handleUnknownResult(r)
}
}
return
}
Expand Down
8 changes: 0 additions & 8 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ type Request struct {
trace *clientTrace
dumpBuffer *bytes.Buffer
responseReturnTime time.Time
unknownResultHandlerFunc func(resp *Response) error
}

type GetContentFunc func() (io.ReadCloser, error)
Expand Down Expand Up @@ -388,13 +387,6 @@ func (r *Request) SetErrorResult(error interface{}) *Request {
return r
}

// SetUnknownResultHandlerFunc set the response handler which will be executed when no
// error occurs, but Response.ResultState returns UnknownState.
func (r *Request) SetUnknownResultHandlerFunc(fn func(resp *Response) error) *Request {
r.unknownResultHandlerFunc = fn
return r
}

// SetBearerAuthToken set bearer auth token for the request.
func (r *Request) SetBearerAuthToken(token string) *Request {
return r.SetHeader("Authorization", "Bearer "+token)
Expand Down
6 changes: 0 additions & 6 deletions request_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ func SetErrorResult(error interface{}) *Request {
return defaultClient.R().SetErrorResult(error)
}

// SetUnknownResultHandlerFunc is a global wrapper methods which delegated
// to the default client, create a request and SetUnknownResultHandlerFunc for request.
func SetUnknownResultHandlerFunc(fn func(resp *Response) error) *Request {
return defaultClient.R().SetUnknownResultHandlerFunc(fn)
}

// SetBearerAuthToken is a global wrapper methods which delegated
// to the default client, create a request and SetBearerAuthToken for request.
func SetBearerAuthToken(token string) *Request {
Expand Down

0 comments on commit f5594c5

Please sign in to comment.