This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package products | |
| import ( | |
| "go-fiber-api-docker/pkg/common/models" | |
| "github.com/gofiber/fiber/v2" | |
| ) | |
| func (h handler) GetProduct(c *fiber.Ctx) error { | |
| id := c.Params("id") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package products | |
| import ( | |
| "go-fiber-api-docker/pkg/common/models" | |
| "github.com/gofiber/fiber/v2" | |
| ) | |
| func (h handler) GetProducts(c *fiber.Ctx) error { | |
| var products []models.Product |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package products | |
| import ( | |
| "go-fiber-api-docker/pkg/common/models" | |
| "github.com/gofiber/fiber/v2" | |
| ) | |
| func (h handler) DeleteProduct(c *fiber.Ctx) error { | |
| id := c.Params("id") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package products | |
| import ( | |
| "go-fiber-api-docker/pkg/common/models" | |
| "github.com/gofiber/fiber/v2" | |
| ) | |
| func (h handler) DeleteProduct(c *fiber.Ctx) error { | |
| id := c.Params("id") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package products | |
| import ( | |
| "go-fiber-api-docker/pkg/common/models" | |
| "github.com/gofiber/fiber/v2" | |
| ) | |
| type AddProductRequestBody struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package products | |
| import ( | |
| "gorm.io/gorm" | |
| ) | |
| type handler struct { | |
| DB *gorm.DB | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package db | |
| import ( | |
| "fmt" | |
| "log" | |
| "go-fiber-api-docker/pkg/common/config" | |
| "go-fiber-api-docker/pkg/common/models" | |
| "gorm.io/driver/postgres" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package models | |
| type Product struct { | |
| Id int `json:"id" gorm:"primaryKey"` | |
| Name string `json:"name"` | |
| Stock int32 `json:"stock"` | |
| Price int32 `json:"price"` | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package config | |
| import ( | |
| "github.com/spf13/viper" | |
| ) | |
| type Config struct { | |
| Port string `mapstructure:"PORT"` | |
| DBHost string `mapstructure:"DB_HOST"` | |
| DBUser string `mapstructure:"DB_USER"` |
NewerOlder