mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
agent/caching: proxy redirect and non-json responses; update tests (#6353)
* agent/caching: proxy redirect and non-json responses; update tests * agent/caching: do not wrap error responses as internal errors, simply proxy them back as-is * minor refactoring of APIProxy.Send logic * add test case to ensure error response is not wrapped
This commit is contained in:
committed by
GitHub
parent
07b18eef6b
commit
ba86e6bbd5
14
command/agent/cache/api_proxy.go
vendored
14
command/agent/cache/api_proxy.go
vendored
@@ -45,13 +45,15 @@ func (ap *APIProxy) Send(ctx context.Context, req *SendRequest) (*SendResponse,
|
||||
|
||||
// Make the request to Vault and get the response
|
||||
ap.logger.Info("forwarding request", "path", req.Request.URL.Path, "method", req.Request.Method)
|
||||
resp, err := client.RawRequestWithContext(ctx, fwReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sendResponse := &SendResponse{
|
||||
Response: resp,
|
||||
var sendResponse *SendResponse
|
||||
resp, err := client.RawRequestWithContext(ctx, fwReq)
|
||||
if resp != nil {
|
||||
sendResponse = &SendResponse{Response: resp}
|
||||
}
|
||||
if err != nil {
|
||||
// Bubble back the api.Response as well for error checking/handling at the handler layer.
|
||||
return sendResponse, err
|
||||
}
|
||||
|
||||
// Set SendResponse.ResponseBody if the response body is non-nil
|
||||
|
||||
Reference in New Issue
Block a user