token-validator: ip, ping, ...
This commit is contained in:
parent
6d6af5f7f4
commit
081b22a64a
5 changed files with 118 additions and 28 deletions
|
@ -107,6 +107,18 @@ func rawHandler(f func(*http.Request, httprouter.Params, []byte) (interface{}, e
|
|||
}
|
||||
}
|
||||
|
||||
func challengeHandler(f func (*http.Request, []byte, int) (interface{}, error)) func(*http.Request, httprouter.Params, []byte) (interface{}, error) {
|
||||
return func(r *http.Request, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
return f(r, body, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func definedChallengeHandler(f func (*http.Request, []byte, int) (interface{}, error), chid int) func(*http.Request, httprouter.Params, []byte) (interface{}, error) {
|
||||
return func(r *http.Request, ps httprouter.Params, body []byte) (interface{}, error) {
|
||||
return f(r, body, chid)
|
||||
}
|
||||
}
|
||||
|
||||
func apiHandler(f DispatchFunction, access ...func(*Student, *http.Request) error) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||
return rawHandler(func (_ *http.Request, ps httprouter.Params, b []byte) (interface{}, error) { return f(ps, b) }, access...)
|
||||
}
|
||||
|
|
Reference in a new issue