Merge branch 'develop'
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Piotr Biernat 2023-04-04 01:09:37 +02:00
commit d3c0a66bd4
2 changed files with 17 additions and 17 deletions

View File

@ -25,17 +25,17 @@ import (
) )
const ( const (
defAppName = "basket-worker" // defAppName = "basket-worker"
defLoggerAddr = "api-logger:24224" // defLoggerAddr = "api-logger:24224"
defRegistryAddr = "api-registry:8500" // defRegistryAddr = "api-registry:8500"
defDbURL = "postgres://postgres:12345678@postgres-db:5432/egommerce" // defDbURL = "postgres://postgres:12345678@postgres-db:5432/egommerce"
defCacheAddr = "api-cache:6379" // defCacheAddr = "api-cache:6379"
defCachePassword = "12345678" // defCachePassword = "12345678"
defMongoDbURL = "mongodb://mongodb:12345678@mongo-db:27017" // defMongoDbURL = "mongodb://mongodb:12345678@mongo-db:27017"
defEventBusURL = "amqp://guest:guest@api-eventbus:5672" // defEventBusURL = "amqp://guest:guest@api-eventbus:5672"
ebEventsExchange = "api-events" // ebEventsExchange = "api-events"
ebEventsQueue = "basket-worker" // ebEventsQueue = "basket-worker"
defKVNmspc = "dev.egommerce/service/basket-worker" // defKVNmspc = "dev.egommerce/service/basket-worker"
) )
func main() { func main() {
@ -169,7 +169,7 @@ func main() {
basket, err := ui.AddProductToBasket(basketSrv, productID, qty, basketID, reqID) basket, err := ui.AddProductToBasket(basketSrv, productID, qty, basketID, reqID)
if err == nil { if err == nil {
logger.Log("Product #%s added to basket #%s. ReqID: #%s", productID, basket.ID, reqID) logger.Log("Product #%d added to basket #%s. ReqID: #%s", productID, basket.ID, reqID)
} }
case strings.Contains(eName, event.EVENT_PRODUCT_REMOVED_FROM_BASKET): case strings.Contains(eName, event.EVENT_PRODUCT_REMOVED_FROM_BASKET):
productID := int(data["product_id"].(float64)) productID := int(data["product_id"].(float64))
@ -177,7 +177,7 @@ func main() {
basket, err := ui.RemoveProductFromBasket(basketSrv, productID, qty, basketID, reqID) basket, err := ui.RemoveProductFromBasket(basketSrv, productID, qty, basketID, reqID)
if err == nil { if err == nil {
logger.Log("Product #%s removed from basket #%s. ReqID: #%s", productID, basket.ID, reqID) logger.Log("Product #%d removed from basket #%s. ReqID: #%s", productID, basket.ID, reqID)
} }
} }

View File

@ -58,20 +58,20 @@ func (s *Server) GetRequestID(c *fiber.Ctx) (string, error) {
// @Refactor make single func with error message and optional http status code... // @Refactor make single func with error message and optional http status code...
func (s *Server) Error400(c *fiber.Ctx, msg string) error { func (s *Server) Error400(c *fiber.Ctx, msg string) error {
return c.Status(fiber.StatusBadRequest).JSON(http.ErrorResponse{msg}) return c.Status(fiber.StatusBadRequest).JSON(http.ErrorResponse{Error: msg})
// test with &(reference) before http.ErrorMessage, but probably it's gonna be erroneous // test with &(reference) before http.ErrorMessage, but probably it's gonna be erroneous
} }
func (s *Server) Error401(c *fiber.Ctx, msg string) error { func (s *Server) Error401(c *fiber.Ctx, msg string) error {
return c.Status(fiber.StatusUnauthorized).JSON(http.ErrorResponse{msg}) return c.Status(fiber.StatusUnauthorized).JSON(http.ErrorResponse{Error: msg})
} }
func (s *Server) Error403(c *fiber.Ctx, msg string) error { func (s *Server) Error403(c *fiber.Ctx, msg string) error {
return c.Status(fiber.StatusForbidden).JSON(http.ErrorResponse{msg}) return c.Status(fiber.StatusForbidden).JSON(http.ErrorResponse{Error: msg})
} }
func (s *Server) Error404(c *fiber.Ctx, msg string) error { func (s *Server) Error404(c *fiber.Ctx, msg string) error {
return c.Status(fiber.StatusNotFound).JSON(http.ErrorResponse{msg}) return c.Status(fiber.StatusNotFound).JSON(http.ErrorResponse{Error: msg})
} }
// @EndRefactor // @EndRefactor