monkeyDluffy6017 commented on code in PR #2634:
URL: https://github.com/apache/apisix-dashboard/pull/2634#discussion_r995591277
##########
api/internal/handler/resources/resources.go:
##########
@@ -106,60 +113,57 @@ func (h *Handler) ProxyResource(c *gin.Context, _
interface{}) handler.Response
}
return handler.Response{
- Success: true,
- Data: h.processResponse(version, data),
+ Success: true,
+ StatusCode: resp.StatusCode(),
+ Data: h.processResponse(version, data),
}
}
// ProxyMisc sends the Admin API response as-is, adding only the wrapping
required by the Dashboard
func (h *Handler) ProxyMisc(c *gin.Context, _ interface{}) handler.Response {
resp, err := h.proxy(c)
if err != nil {
- return *err
+ return handler.Response{
+ Success: false,
+ ErrMsg: err.Error(),
+ }
}
data := gjson.ParseBytes(resp.Body())
if err := h.extractError(data); err != nil {
- return *err
+ return handler.Response{
+ Success: false,
+ StatusCode: resp.StatusCode(),
+ ErrMsg: err.Error(),
+ }
}
return handler.Response{
- Success: true,
- Data: data.Value(),
+ Success: true,
+ StatusCode: resp.StatusCode(),
+ Data: data.Value(),
}
}
// proxy forwards user requests for these interfaces to the Admin API as-is.
-func (h *Handler) proxy(c *gin.Context) (*resty.Response, *handler.Response) {
+func (h *Handler) proxy(c *gin.Context) (*resty.Response, error) {
Review Comment:
I want to get the type of the error and handle it uniformly in the outer
layer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]