Files
satusehat-bridging/internal/handler/oauth_handler.go
2025-11-24 09:13:08 +07:00

34 lines
662 B
Go

package handler
import (
"net/http"
"satusehat-rssa/internal/integration"
"satusehat-rssa/internal/model"
"github.com/gin-gonic/gin"
)
type OauthHandler struct {
Oauth integration.OauthInterface
}
func NewOuathHandler(Oauth integration.OauthInterface) *OauthHandler {
return &OauthHandler{Oauth: Oauth}
}
func (oh OauthHandler) GenerateToken(c *gin.Context) {
var bodyParam model.OauthRequest
if err := c.ShouldBindJSON(&bodyParam); err != nil {
c.JSON(http.StatusBadRequest, err)
return
}
res, err := oh.Oauth.GenerateToken(bodyParam)
if err != nil {
c.JSON(http.StatusInternalServerError, err)
return
}
c.JSON(http.StatusOK, res)
}