forked from ebhomengo/niki
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package benefactorhandler
|
|
|
|
import (
|
|
benefactorparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactor"
|
|
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// RefreshAccess godoc
|
|
// @Summary Get a new access token by providing your refresh token
|
|
// @Tags Benefactors
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param Request body benefactorparam.RefreshAccessRequest true "Refresh access token request body"
|
|
// @Success 200 {object} benefactorparam.RefreshAccessResponse
|
|
// @Failure 400 {string} "Bad Request"
|
|
// @Failure 500 {string} "something went wrong"
|
|
// @Router /benefactors/refresh-access [post].
|
|
func (h Handler) RefreshAccess(c echo.Context) error {
|
|
var req benefactorparam.RefreshAccessRequest
|
|
|
|
if err := c.Bind(&req); err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest)
|
|
}
|
|
|
|
resp, err := h.benefactorSvc.RefreshAccess(c.Request().Context(), req)
|
|
if err != nil {
|
|
msg, code := httpmsg.Error(err)
|
|
|
|
return echo.NewHTTPError(code, msg)
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, resp)
|
|
}
|