Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGinRefererMiddleware ¶
func NewGinRefererMiddleware(builders []*RefererVerifierBuilder) (gin.HandlerFunc, error)
Types ¶
type RefererVerifier ¶
type RefererVerifier struct {
// contains filtered or unexported fields
}
func (*RefererVerifier) Verify ¶
func (verifier *RefererVerifier) Verify(route, referer string) (bool, string)
Verify 验证referer
@param route 请求的路由(可以通过 ctx.FullPath() 获取) @param referer 请求的referer(可能为"") @return 验证是否通过 + 验证失败的原因
func (*RefererVerifier) VerifyByGinContext ¶
func (verifier *RefererVerifier) VerifyByGinContext(ctx *gin.Context) (bool, string)
VerifyByGinContext 验证referer
type RefererVerifierBuilder ¶
type RefererVerifierBuilder struct { None bool Blocked bool // Route 路由的正则字符串 Route string // ServerNames referer白名单的正则字符串s ServerNames []string }
func (*RefererVerifierBuilder) Build ¶
func (builder *RefererVerifierBuilder) Build() (*RefererVerifier, error)
Click to show internal directories.
Click to hide internal directories.