Use pointer instead of struct

This commit is contained in:
nemunaire 2021-03-07 12:39:38 +01:00
commit 6d8f38d749
18 changed files with 187 additions and 142 deletions

View file

@ -19,7 +19,7 @@ type checkGLUE struct {
}
func init() {
router.POST("/api/check/GLUE", apiAuthHandler(func(student adlin.Student, ps httprouter.Params, body []byte) (interface{}, error) {
router.POST("/api/check/GLUE", apiAuthHandler(func(student *adlin.Student, ps httprouter.Params, body []byte) (interface{}, error) {
var uc checkGLUE
if err := json.Unmarshal(body, &uc); err != nil {
return nil, err
@ -27,7 +27,7 @@ func init() {
return true, check_GLUE_respond(student, uc.Domain, uc.IP)
}))
}
func check_GLUE_respond(student adlin.Student, domain string, ip string) (err error) {
func check_GLUE_respond(student *adlin.Student, domain string, ip string) (err error) {
if !strings.HasPrefix(ip, adlin.StudentIP(student.Id).String()) {
return fmt.Errorf("%q is not your IP range")
}