2016-04-03 17:59:27 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MethodData is a struct containing the data passed over to an API method.
|
|
|
|
type MethodData struct {
|
|
|
|
User Token
|
|
|
|
DB *sql.DB
|
|
|
|
RequestData []byte
|
|
|
|
C *gin.Context
|
|
|
|
}
|
2016-04-08 17:05:54 +00:00
|
|
|
|
|
|
|
// Err logs an error into gin.
|
|
|
|
func (md MethodData) Err(err error) {
|
|
|
|
md.C.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ID retrieves the Token's owner user ID.
|
|
|
|
func (md MethodData) ID() int {
|
|
|
|
return md.User.UserID
|
|
|
|
}
|