improve error handling
This commit is contained in:
@@ -51,13 +51,17 @@ func RetrieveSecret(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(results) > 1 {
|
||||
if len(results) == 1 {
|
||||
// output results as json
|
||||
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results})
|
||||
} else if len(results) > 1 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "found multiple matching secrets, use retrieveMultiple instead"})
|
||||
return
|
||||
} else {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "found no matching secrets"})
|
||||
return
|
||||
}
|
||||
|
||||
// output results as json
|
||||
c.JSON(http.StatusOK, gin.H{"message": "success", "data": results})
|
||||
}
|
||||
|
||||
func RetrieveMultpleSecrets(c *gin.Context) {
|
||||
|
Reference in New Issue
Block a user