20 lines
453 B
Go
20 lines
453 B
Go
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
|
|
}
|
|
}
|