Use pointer instead of struct
This commit is contained in:
parent
853477e54a
commit
6d8f38d749
18 changed files with 187 additions and 142 deletions
|
@ -11,13 +11,13 @@ var PongSecret = "felixfixit"
|
|||
|
||||
func init() {
|
||||
router.GET("/api/students/:sid/ping", apiHandler(studentHandler(lastPing)))
|
||||
router.GET("/api/students/:sid/pong", apiHandler(studentHandler(func(student adlin.Student, body []byte) (interface{}, error) {
|
||||
router.GET("/api/students/:sid/pong", apiHandler(studentHandler(func(student *adlin.Student, body []byte) (interface{}, error) {
|
||||
return student.LastPongs()
|
||||
})))
|
||||
router.POST("/api/students/:sid/pong", apiHandler(studentHandler(stdPong), sslOnly))
|
||||
}
|
||||
|
||||
func lastPing(student adlin.Student, body []byte) (interface{}, error) {
|
||||
func lastPing(student *adlin.Student, body []byte) (interface{}, error) {
|
||||
if pongs, err := student.LastPongs(); err != nil {
|
||||
return nil, err
|
||||
} else if len(pongs) <= 0 {
|
||||
|
@ -27,7 +27,7 @@ func lastPing(student adlin.Student, body []byte) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func stdPong(student adlin.Student, body []byte) (interface{}, error) {
|
||||
func stdPong(student *adlin.Student, body []byte) (interface{}, error) {
|
||||
var gt givenToken
|
||||
if err := json.Unmarshal(body, >); err != nil {
|
||||
return nil, err
|
||||
|
|
Reference in a new issue