Documentation ¶
Index ¶
- Variables
- func BanAPIForUserCenter(ctx *gin.Context)
- func ExtractAndSetAcceptLanguage(ctx *gin.Context)
- func ExtractToken(ctx *gin.Context) (token string)
- func GetIsAdminFromContext(ctx *gin.Context) (isAdmin bool)
- func GetLoginUserIDFromContext(ctx *gin.Context) (userID string)
- func GetLoginUserIDInt64FromContext(ctx *gin.Context) (userID int64)
- func GetUserInfoFromContext(ctx *gin.Context) (u *entity.UserCacheInfo)
- func GetUserIsAdminModerator(ctx *gin.Context) (isAdminModerator bool)
- func HeadersByRequestURI() gin.HandlerFunc
- func ShowIndexPage(ctx *gin.Context)
- type AuthUserMiddleware
- func (am *AuthUserMiddleware) AdminAuth() gin.HandlerFunc
- func (am *AuthUserMiddleware) Auth() gin.HandlerFunc
- func (am *AuthUserMiddleware) CheckPrivateMode() gin.HandlerFunc
- func (am *AuthUserMiddleware) EjectUserBySiteInfo() gin.HandlerFunc
- func (am *AuthUserMiddleware) MustAuthAndAccountAvailable() gin.HandlerFunc
- func (am *AuthUserMiddleware) MustAuthWithoutAccountAvailable() gin.HandlerFunc
- func (am *AuthUserMiddleware) VisitAuth() gin.HandlerFunc
- type AvatarMiddleware
- type RateLimitMiddleware
- type ShortIDMiddleware
Constants ¶
This section is empty.
Variables ¶
var ProviderSetMiddleware = wire.NewSet( NewAuthUserMiddleware, NewAvatarMiddleware, NewShortIDMiddleware, NewRateLimitMiddleware, )
ProviderSetMiddleware is providers.
Functions ¶
func BanAPIForUserCenter ¶
BanAPIForUserCenter ban api for user center
func ExtractAndSetAcceptLanguage ¶
ExtractAndSetAcceptLanguage extract accept language from header and set to context
func ExtractToken ¶
ExtractToken extract token from context
func GetIsAdminFromContext ¶
GetIsAdminFromContext get user is admin from context
func GetLoginUserIDFromContext ¶
GetLoginUserIDFromContext get user id from context
func GetUserInfoFromContext ¶
func GetUserInfoFromContext(ctx *gin.Context) (u *entity.UserCacheInfo)
GetUserInfoFromContext get user info from context
func GetUserIsAdminModerator ¶
func HeadersByRequestURI ¶
func HeadersByRequestURI() gin.HandlerFunc
func ShowIndexPage ¶
Types ¶
type AuthUserMiddleware ¶
type AuthUserMiddleware struct {
// contains filtered or unexported fields
}
AuthUserMiddleware auth user middleware
func NewAuthUserMiddleware ¶
func NewAuthUserMiddleware( authService *auth.AuthService, siteInfoCommonService siteinfo_common.SiteInfoCommonService) *AuthUserMiddleware
NewAuthUserMiddleware new auth user middleware
func (*AuthUserMiddleware) AdminAuth ¶
func (am *AuthUserMiddleware) AdminAuth() gin.HandlerFunc
func (*AuthUserMiddleware) Auth ¶
func (am *AuthUserMiddleware) Auth() gin.HandlerFunc
Auth get token and auth user, set user info to context if user is already login
func (*AuthUserMiddleware) CheckPrivateMode ¶
func (am *AuthUserMiddleware) CheckPrivateMode() gin.HandlerFunc
func (*AuthUserMiddleware) EjectUserBySiteInfo ¶
func (am *AuthUserMiddleware) EjectUserBySiteInfo() gin.HandlerFunc
EjectUserBySiteInfo if admin config the site can access by nologin user, eject user.
func (*AuthUserMiddleware) MustAuthAndAccountAvailable ¶ added in v1.2.5
func (am *AuthUserMiddleware) MustAuthAndAccountAvailable() gin.HandlerFunc
MustAuthAndAccountAvailable auth user info and check user status, only allow active user access.
func (*AuthUserMiddleware) MustAuthWithoutAccountAvailable ¶ added in v1.2.5
func (am *AuthUserMiddleware) MustAuthWithoutAccountAvailable() gin.HandlerFunc
MustAuthWithoutAccountAvailable auth user info, any login user can access though user is not active.
func (*AuthUserMiddleware) VisitAuth ¶
func (am *AuthUserMiddleware) VisitAuth() gin.HandlerFunc
VisitAuth when user visit the site image, check visit token. This only for private mode.
type AvatarMiddleware ¶
type AvatarMiddleware struct {
// contains filtered or unexported fields
}
func NewAvatarMiddleware ¶
func NewAvatarMiddleware(serviceConfig *service_config.ServiceConfig, uploaderService uploader.UploaderService, ) *AvatarMiddleware
NewAvatarMiddleware new auth user middleware
func (*AvatarMiddleware) AvatarThumb ¶
func (am *AvatarMiddleware) AvatarThumb() gin.HandlerFunc
type RateLimitMiddleware ¶
type RateLimitMiddleware struct {
// contains filtered or unexported fields
}
func NewRateLimitMiddleware ¶
func NewRateLimitMiddleware(limitRepo *limit.LimitRepo) *RateLimitMiddleware
NewRateLimitMiddleware new rate limit middleware
func (*RateLimitMiddleware) DuplicateRequestClear ¶
func (rm *RateLimitMiddleware) DuplicateRequestClear(ctx *gin.Context, key string)
DuplicateRequestClear clear duplicate request record
func (*RateLimitMiddleware) DuplicateRequestRejection ¶
func (rm *RateLimitMiddleware) DuplicateRequestRejection(ctx *gin.Context, req any) (reject bool, key string)
DuplicateRequestRejection detects and rejects duplicate requests It only works for the requests that post content. Such as add question, add answer, comment etc.
type ShortIDMiddleware ¶
type ShortIDMiddleware struct {
// contains filtered or unexported fields
}
func NewShortIDMiddleware ¶
func NewShortIDMiddleware(siteInfoService siteinfo_common.SiteInfoCommonService) *ShortIDMiddleware
func (*ShortIDMiddleware) SetShortIDFlag ¶
func (sm *ShortIDMiddleware) SetShortIDFlag() gin.HandlerFunc