package server

import (
	"net/http"

	"git.pbiernat.dev/egommerce/identity-service/internal/service"
	"github.com/gofiber/fiber/v2"
)

type TraefikAuthResponse struct {
	Status  string `json:"status,omitempty"`
	Message string `json:"msg,omitempty"`
}

func (s *Server) TraefikHandler(c *fiber.Ctx) error {
	cookie := service.AuthService.Cookie("traefik", "tmp-dummy-traefik-token")

	c.Cookie(cookie)
	s.Logger.Log("Traefik action set cookie. done.")

	c.Response().Header.Add("Server", "identity-svc/traefik")
	reqCookie := c.Request().Header.Cookie("basket_id")
	s.Logger.Log("Request cookie: %v", reqCookie)

	return c.
		Status(http.StatusOK).
		JSON(&TraefikAuthResponse{Status: "OK"})
	// return c.
	// 	Status(http.StatusUnauthorized).
	// 	JSON(&TraefikAuthResponse{Message: "Access denied mf..."})
}
