Skip to content

Commit

Permalink
fix backups update param
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Aug 8, 2023
1 parent 862375c commit e7f83a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

APP_NAME=swis-api
APP_ROOT=/opt/${APP_NAME}
APP_VERSION=5.5.7
APP_VERSION=5.5.8


#
Expand Down
16 changes: 8 additions & 8 deletions backups/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ func PostDumpRestore(ctx *gin.Context) {
// @Param request body backups.Backup.ServiceName true "query params"
// @Success 200 {object} backups.Backup
// @Router /backups/{key} [put]
func UpdateBackupStatusByServiceKey(c *gin.Context) {
func UpdateBackupStatusByServiceKey(ctx *gin.Context) {
var updatedService Backup
var postedService Backup

var name string = c.Param("service")
var name string = ctx.Param("key")

rawService, found := Cache.Get(name)
if !found {
c.IndentedJSON(http.StatusNotFound, gin.H{
ctx.IndentedJSON(http.StatusNotFound, gin.H{
"code": http.StatusNotFound,
"message": "backed up service not found by its name",
"name": name,
Expand All @@ -95,15 +95,15 @@ func UpdateBackupStatusByServiceKey(c *gin.Context) {

updatedService, ok := rawService.(Backup)
if !ok {
c.IndentedJSON(http.StatusInternalServerError, gin.H{
ctx.IndentedJSON(http.StatusInternalServerError, gin.H{
"message": "cannot assert data type, database internal error",
"code": http.StatusInternalServerError,
})
return
}

if err := c.BindJSON(&postedService); err != nil {
c.IndentedJSON(http.StatusBadRequest, gin.H{
if err := ctx.BindJSON(&postedService); err != nil {
ctx.IndentedJSON(http.StatusBadRequest, gin.H{
"code": http.StatusBadRequest,
"message": "cannot parse input JSON stream",
})
Expand All @@ -118,14 +118,14 @@ func UpdateBackupStatusByServiceKey(c *gin.Context) {
updatedService.Size = postedService.Size

if saved := Cache.Set(name, updatedService); !saved {
c.IndentedJSON(http.StatusInternalServerError, gin.H{
ctx.IndentedJSON(http.StatusInternalServerError, gin.H{
"code": http.StatusInternalServerError,
"message": "backed up service couldn't be saved to database",
})
return
}

c.IndentedJSON(http.StatusOK, gin.H{
ctx.IndentedJSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"message": "backed up service updated",
"backup": updatedService,
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @title swis-api (swapi) v5
// @version 5.5.7
// @version 5.5.8
// @description sakalWeb Information System v5 RESTful API documentation
// @termsOfService http://swagger.io/terms/

Expand Down

0 comments on commit e7f83a6

Please sign in to comment.