Skip to content

Commit

Permalink
clean up some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphomberger committed Mar 29, 2024
1 parent 8ed7d9d commit b0121ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 61 deletions.
42 changes: 0 additions & 42 deletions albums.go

This file was deleted.

17 changes: 1 addition & 16 deletions application.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"ginapi/configs"
"ginapi/routes"
"github.com/gin-gonic/gin"
Expand All @@ -12,20 +11,6 @@ func main() {
r := gin.Default()
routes.AlbumsRoute(r)
//run database
var client = configs.ConnectDB()
fmt.Println(configs.GetCollection(client, "albums"))
configs.ConnectDB()
r.Run(":8080")
}

func getHome(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Welcome to the API!",
})
}

func getUser(c *gin.Context) {
name := c.Param("name")
c.JSON(200, gin.H{
"message": "Hello, " + name + "!",
})
}
6 changes: 3 additions & 3 deletions controllers/album.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func GetAlbums() gin.HandlerFunc {
for _, doc := range results {
fmt.Println(doc)
}
c.JSON(http.StatusCreated, responses.AlbumResponse{Status: http.StatusCreated, Message: "success", Data: map[string]interface{}{"data": results}})
c.JSON(http.StatusOK, responses.AlbumResponse{Status: http.StatusOK, Message: "success", Data: map[string]interface{}{"data": results}})
}
}

Expand All @@ -89,7 +89,7 @@ func GetAlbum() gin.HandlerFunc {
}
panic(err)
}
c.JSON(http.StatusCreated, responses.AlbumResponse{Status: http.StatusCreated, Message: "success", Data: map[string]interface{}{"data": result}})
c.JSON(http.StatusOK, responses.AlbumResponse{Status: http.StatusOK, Message: "success", Data: map[string]interface{}{"data": result}})
}
}

Expand All @@ -108,7 +108,7 @@ func DelAlbum() gin.HandlerFunc {
}
panic(err)
}
c.JSON(http.StatusCreated, responses.AlbumResponse{Status: http.StatusCreated, Message: "success delete", Data: map[string]interface{}{"data": result}})
c.JSON(http.StatusOK, responses.AlbumResponse{Status: http.StatusOK, Message: "success delete", Data: map[string]interface{}{"data": result}})
}
}

Expand Down

0 comments on commit b0121ef

Please sign in to comment.