package handlers import ( "git.itzana.me/StrafesNET/dev-service/pkg/api/dto" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" "net/http" ) // ConfigHandler handles HTTP requests related to config. type ConfigHandler struct { *Handler } // NewConfigHandler creates a new ConfigHandler with the provided options. // It requires both a datastore and an authentication service to function properly. func NewConfigHandler(options ...HandlerOption) (*ConfigHandler, error) { baseHandler, err := NewHandler(options...) if err != nil { return nil, err } return &ConfigHandler{ Handler: baseHandler, }, nil } func (h *ConfigHandler) GetConfig(ctx *gin.Context) { metadata, err := h.Auth.GetAuthMetadata(ctx) if err != nil { h.RespondWithError(ctx, http.StatusInternalServerError, "Failed to get auth metadata") log.WithError(err).Error("failed to get auth metadata") return } h.RespondWithData(ctx, dto.Config{ AuthMetadata: dto.AuthMetadata{ LoginUrl: metadata.LoginURL, LogoutUrl: metadata.LogoutURL, ManageUrl: metadata.AccountURL, }, }, nil) }