Files
n.nakhostin 00ad7e136d Enhance API Documentation for Notification Target Audience
- Added "target" field reference to the notification request and response structures in Swagger documentation, improving clarity for API consumers.
- Introduced "notification.TargetAudienceType" definition with enumerated values for target audience options, enhancing the API's usability and understanding.
- Updated related documentation files (YAML and JSON) to reflect these changes, ensuring consistency across all API documentation formats.
2025-09-17 16:05:33 +03:30

66 lines
2.0 KiB
Go

package assets
import (
"net/http"
"tm/pkg/logger"
"github.com/labstack/echo/v4"
)
// Handler handles HTTP requests for flag operations
type Handler struct {
service Service
logger logger.Logger
}
// NewHandler creates a new flag handler
func NewHandler(service Service, logger logger.Logger) *Handler {
return &Handler{
service: service,
logger: logger,
}
}
// **************************** PUBLIC ENDPOINTS ****************************
// GetFlagSVG returns only the SVG content of a flag
// @Summary Get flag SVG
// @Description Retrieve only the SVG content of a country flag by its 3-letter country code
// @Tags Flags
// @Accept json
// @Produce image/svg+xml
// @Param country_code path string true "3-letter country code (e.g., POL, GRC)"
// @Success 200 {string} string "SVG content"
// @Router /api/v1//{country_code} [get]
func (h *Handler) GetFlagSVG(c echo.Context) error {
countryCode := c.Param("country_code")
svgData := h.service.GetFlagSVG(c.Request().Context(), countryCode)
c.Response().Header().Set("Content-Type", "image/svg+xml")
c.Response().Header().Set("Cache-Control", "public, max-age=86400") // Cache for 24 hours
return c.String(http.StatusOK, svgData)
}
// **************************** ADMIN ENDPOINTS ****************************
// AdminGetFlag returns a flag by country code (Admin)
// @Summary Get flag by country code (Admin)
// @Description Retrieve a country flag by its 3-letter country code for admin panel
// @Tags Admin-Flags
// @Accept json
// @Produce json
// @Param country_code path string true "3-letter country code (e.g., POL, GRC)"
// @Success 200 {string} string "SVG content"
// @Security BearerAuth
// @Router /admin/v1/flags/{country_code} [get]
func (h *Handler) AdminGetFlagSVG(c echo.Context) error {
countryCode := c.Param("country_code")
svgData := h.service.GetFlagSVG(c.Request().Context(), countryCode)
c.Response().Header().Set("Content-Type", "image/svg+xml")
c.Response().Header().Set("Cache-Control", "public, max-age=86400") // Cache for 24 hours
return c.String(http.StatusOK, svgData)
}