From: bruce Date: Tue, 13 Jun 2023 02:44:41 +0000 (+0800) Subject: feat(service): add callback function of CheckToken. X-Git-Tag: v0.2.2 X-Git-Url: https://git.uzoombox.com/git/?a=commitdiff_plain;h=6f094502a239ba84b4f63442d9ea3f60e77ae715;p=uzsdk-v0.3.1.git feat(service): add callback function of CheckToken. --- diff --git a/uzsdk/service.go b/uzsdk/service.go index 503ce1e..f513d83 100644 --- a/uzsdk/service.go +++ b/uzsdk/service.go @@ -128,11 +128,22 @@ func Respcode(code string, options ...interface{}) Respnode { } } +// RequireResource defines resource that required by an operation. +type RequireResource struct { + Operation string // add, del, set, get, list, upload, download, view, print, edit... + FileIds []string // fs_file_id + ShareIds []string // fs_share_id +} + +// TokenCheckFunc defines function type of check client privilege by token. +type TokenCheckFunc func(token string, options ...interface{}) bool + // Instance is the framework's instance, used for server & plugin both. type Instance struct { - Conf *Configuration // configuration of this application. - Db *sqlx.DB // the first database connection created by main routine. - Logger *logger.Logger // logger created by main routine. - Router *gin.Engine // default webservice engine created by main routine. - Maintenance bool // when maintenance mode is true, only serve api /config. + Conf *Configuration // configuration of this application. + Db *sqlx.DB // the first database connection created by main routine. + Logger *logger.Logger // logger created by main routine. + Router *gin.Engine // default webservice engine created by main routine. + Maintenance bool // when maintenance mode is true, only serve api /config. + CheckToken *TokenCheckFunc // pointer of check token function. }