Merge pull request #1160 from RRCAT920/update-zh-04.4.md
Update zh/04.4.md
This commit is contained in:
@@ -21,10 +21,10 @@
|
|||||||
func login(w http.ResponseWriter, r *http.Request) {
|
func login(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Println("method:", r.Method) //获取请求的方法
|
fmt.Println("method:", r.Method) //获取请求的方法
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
crutime := time.Now().Unix()
|
timestamp := strconv.Itoa(time.Now().Nanosecond())
|
||||||
h := md5.New()
|
hashWr := md5.New()
|
||||||
io.WriteString(h, strconv.FormatInt(crutime, 10))
|
hashWr.Write([]byte(timestamp))
|
||||||
token := fmt.Sprintf("%x", h.Sum(nil))
|
token := fmt.Sprintf("%x", hashWr.Sum(nil))
|
||||||
|
|
||||||
t, _ := template.ParseFiles("login.gtpl")
|
t, _ := template.ParseFiles("login.gtpl")
|
||||||
t.Execute(w, token)
|
t.Execute(w, token)
|
||||||
|
|||||||
Reference in New Issue
Block a user