17 lines
455 B
Go
17 lines
455 B
Go
|
|
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)
|
|||
|
|
}
|