package controllers import ( "net/http" "learnsteam/learsteam-quiz-api/internal/models" "learnsteam/learsteam-quiz-api/internal/services" "github.com/gin-gonic/gin" ) type TokenController interface { Refresh(*gin.Context) } type tokenController struct { service services.TokenService } func NewTokenController(service services.TokenService) TokenController { return &tokenController{ service: service, } } // Refresh Token // // @Summary AccessToken Refresh // @Description AccessToken을 RefreshToken으로 갱신합니다. // @Tags Token // // @Accept json // @Produce json // // @Param refresh_token body string true "RefreshToken" // // @Router /token/refresh [post] // @Success 200 {object} models.ProgramResponse func (controller *tokenController) Refresh(c *gin.Context) { var request models.RefreshTokenRequest if err := c.ShouldBindJSON(&request); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } result, err := controller.service.Refresh(request.RefreshToken) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, result) }