From ce4d4694660b10753280e2bb817d1e742784a318 Mon Sep 17 00:00:00 2001 From: Florian Beisel Date: Thu, 18 Jan 2024 00:10:48 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Begin=20implementing=20the=20Mod?= =?UTF-8?q?els?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/handlers.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/handlers.go b/api/handlers.go index d4ee8ff..250dea7 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -6,6 +6,7 @@ import ( "strings" "git.beisel.it/florian/hostname-service/db" + "git.beisel.it/florian/hostname-service/models" "git.beisel.it/florian/hostname-service/rules" "github.com/gin-gonic/gin" ) @@ -65,7 +66,8 @@ func CreateOrUpdateHostname(c *gin.Context, isUpdate bool) { return } - c.JSON(http.StatusOK, gin.H{"hostname": hostname}) + response := models.SimpleHostnameResponse{Hostname: hostname} + c.JSON(http.StatusOK, response) } // @Summary Delete a hostname from the database @@ -87,7 +89,8 @@ func DeleteHostname(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - c.JSON(http.StatusOK, gin.H{"hostname": hostname}) + response := models.SimpleHostnameResponse{Hostname: hostname} + c.JSON(http.StatusOK, response) } // @Summary Return a list of hosts and their details filtered by category