perhaps a memory/performance improvement? by not recreating the same function over and over? maybe.

This commit is contained in:
Howl 2016-04-08 17:27:55 +02:00
parent ed2778e2cc
commit e3cb4aed09

View File

@ -11,6 +11,11 @@ import (
// Method wraps an API method to a HandlerFunc.
func Method(f func(md common.MethodData) common.Response, db *sql.DB, privilegesNeeded ...int) gin.HandlerFunc {
return func(c *gin.Context) {
initialCaretaker(c, f, db, privilegesNeeded...)
}
}
func initialCaretaker(c *gin.Context, f func(md common.MethodData) common.Response, db *sql.DB, privilegesNeeded ...int) {
data, err := ioutil.ReadAll(c.Request.Body)
if err != nil {
c.Error(err)
@ -63,4 +68,3 @@ func Method(f func(md common.MethodData) common.Response, db *sql.DB, privileges
c.IndentedJSON(resp.Code, resp)
}
}
}