34 lines
626 B
Go
34 lines
626 B
Go
package handler
|
|
|
|
import (
|
|
"errors"
|
|
"math/rand"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"myschools.me/campus/campus-core/campus"
|
|
)
|
|
|
|
func HealthCheck(c *gin.Context) {
|
|
|
|
c.JSON(http.StatusOK, nil)
|
|
}
|
|
|
|
func TokenVerify(c *gin.Context) {
|
|
|
|
reqid := campus.NewRequestID(nil)
|
|
token := c.GetHeader("Authorization")
|
|
|
|
source := rand.NewSource(time.Now().Unix())
|
|
r := rand.New(source)
|
|
time.Sleep(time.Duration(r.Intn(300)) * time.Millisecond)
|
|
|
|
if token != "112233" {
|
|
campus.RespBadRequest(c, "token err", errors.New("token err"), &reqid)
|
|
} else {
|
|
campus.RespSuccess(c, "helo_word", token+"helo_word", &reqid)
|
|
}
|
|
|
|
}
|