rubbishclass-srv/admin/admin-handler.go

17 lines
455 B
Go
Raw Normal View History

2020-03-19 12:35:09 +00:00
package admin
import (
"net/http"
"github.com/gin-gonic/gin"
)
//HomeHandle 基础验证试验
//HTTP基本认证(Basic Authentication)
//"用户名+冒号+密码"用BASE64算法加密后的字符串放在http request 中的header的Authorization中发送给服务端
//最终格式Authorization: Basic BASE64("用户名+冒号+密码")
func HomeHandle(c *gin.Context) {
user := c.MustGet(gin.AuthUserKey).(string)
c.JSON(http.StatusOK, user)
}