WIP ping support

This commit is contained in:
nemunaire 2019-02-27 00:19:17 +01:00
parent 82f83e3d89
commit 792f6bbe25
2 changed files with 29 additions and 1 deletions

19
token-validator/ping.go Normal file
View file

@ -0,0 +1,19 @@
package main
import (
"time"
)
func init() {
router.POST("/api/students/:sid/pong", apiHandler(studentHandler(stdPong), sslOnly))
}
func stdPong(student Student, body []byte) (interface{}, error) {
if res, err := DBExec("INSERT INTO student_pong (id_student, time) VALUES (?, ?)", student.Id, time.Now()); err != nil {
return false, err
} else if _, err := res.LastInsertId(); err != nil {
return false, err
} else {
return true, err
}
}