middleware

package
v0.0.0-...-883d24b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSetMiddleware is providers.

Functions

func BanAPIForUserCenter

func BanAPIForUserCenter(ctx *gin.Context)

BanAPIForUserCenter ban api for user center

func ExtractAndSetAcceptLanguage

func ExtractAndSetAcceptLanguage(ctx *gin.Context)

ExtractAndSetAcceptLanguage extract accept language from header and set to context

func ExtractToken

func ExtractToken(ctx *gin.Context) (token string)

ExtractToken extract token from context

func GetIsAdminFromContext

func GetIsAdminFromContext(ctx *gin.Context) (isAdmin bool)

GetIsAdminFromContext get user is admin from context

func GetLoginUserIDFromContext

func GetLoginUserIDFromContext(ctx *gin.Context) (userID string)

GetLoginUserIDFromContext get user id from context

func GetLoginUserIDInt64FromContext

func GetLoginUserIDInt64FromContext(ctx *gin.Context) (userID int64)

func GetUserInfoFromContext

func GetUserInfoFromContext(ctx *gin.Context) (u *entity.UserCacheInfo)

GetUserInfoFromContext get user info from context

func GetUserIsAdminModerator

func GetUserIsAdminModerator(ctx *gin.Context) (isAdminModerator bool)

func HeadersByRequestURI

func HeadersByRequestURI() gin.HandlerFunc

func ShowIndexPage

func ShowIndexPage(ctx *gin.Context)

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) MustAuth

func (am *AuthUserMiddleware) MustAuth() gin.HandlerFunc

MustAuth auth user info. If the user does not log in, an unauthenticated error is displayed

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL