Skip to content

Commit

Permalink
Update middleware_example_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tangfc authored Dec 21, 2024
1 parent 9767267 commit ff66565
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/adapters/goframe/middleware_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ func Example() {
s := g.Server()
s.Use(
SentinelMiddleware(
// 自定义资源提取器
// customize resource extractor if required
WithResourceExtractor(func(r *ghttp.Request) string {
if res, ok := r.Header["X-Real-IP"]; ok && len(res) > 0 {
return res[0]
}
return ""
}),
// 自定义阻塞回退
// customize block fallback if required
WithBlockFallback(func(r *ghttp.Request) {
r.Response.WriteHeader(400)
r.Response.WriteJson(map[string]interface{}{
Expand Down

0 comments on commit ff66565

Please sign in to comment.