You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"git.sp4ke.xyz/AnisB/shelf_api_go/controllers"
|
|
|
|
"git.sp4ke.xyz/AnisB/shelf_api_go/db_client"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
db_client.InitialiseDBConnection()
|
|
|
|
|
|
|
|
r := gin.Default()
|
|
|
|
|
|
|
|
r.GET("/", func(ctx *gin.Context) {
|
|
|
|
ctx.JSON(http.StatusOK, gin.H{"status": "success", "message": "Welcome to Golang with PostgreSQL"})
|
|
|
|
})
|
|
|
|
|
|
|
|
// Products
|
|
|
|
r.GET("/products", controllers.GetProducts)
|
|
|
|
r.GET("/products/:id", controllers.GetProduct)
|
|
|
|
r.POST("/products", controllers.CreateProduct)
|
|
|
|
r.PUT("products/:id", controllers.UpdateProduct)
|
|
|
|
r.DELETE("products/:id", controllers.DeleteProduct)
|
|
|
|
|
|
|
|
if err := r.Run(":5000"); err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
/*router := server.Group("/api")
|
|
|
|
|
|
|
|
router.GET("/healthchecker", func(ctx *gin.Context) {
|
|
|
|
ctx.JSON(http.StatusOK, gin.H{"status": "success", "message": "Welcome to Golang with PostgreSQL"})
|
|
|
|
})
|
|
|
|
|
|
|
|
log.Fatal(server.Run(":" + config.PostgresPort))*/
|
|
|
|
}
|