perhaps a memory/performance improvement? by not recreating the same function over and over? maybe.
This commit is contained in:
parent
ed2778e2cc
commit
e3cb4aed09
|
@ -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)
|
||||
|
@ -62,5 +67,4 @@ func Method(f func(md common.MethodData) common.Response, db *sql.DB, privileges
|
|||
} else {
|
||||
c.IndentedJSON(resp.Code, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user