Files
go-gin-api/internal/web/controller/authorized_handler/func_apiview.go
T
2021-03-28 15:52:02 +08:00

37 lines
756 B
Go

package authorized_handler
import (
"net/http"
"github.com/xinliangnote/go-gin-api/internal/api/code"
"github.com/xinliangnote/go-gin-api/internal/pkg/core"
"github.com/xinliangnote/go-gin-api/pkg/errno"
)
type apiViewRequest struct {
Id string `uri:"id"` // 主键ID
}
type apiViewResponse struct {
HashID string `json:"hash_id"` // hashID
}
func (h *handler) ApiView() core.HandlerFunc {
return func(c core.Context) {
req := new(apiViewRequest)
if err := c.ShouldBindURI(req); err != nil {
c.AbortWithError(errno.NewError(
http.StatusBadRequest,
code.ParamBindError,
code.Text(code.ParamBindError)).WithErr(err),
)
return
}
obj := new(apiViewResponse)
obj.HashID = req.Id
c.HTML("authorized_api", obj)
}
}