mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 23:12:17 +08:00
fix 🐨
This commit is contained in:
parent
2d426b64c3
commit
fc99953b7f
12
README.md
12
README.md
@ -2132,9 +2132,9 @@ other option.
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -2142,14 +2142,14 @@ func main() {
|
|||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
router.TrustedProxies = []string{"192.168.1.2"}
|
router.TrustedProxies = []string{"192.168.1.2"}
|
||||||
|
|
||||||
router.GET("/", func(c *gin.Context) {
|
router.GET("/", func(c *gin.Context) {
|
||||||
// If the client is 192.168.1.2, use the X-Forwarded-For
|
// If the client is 192.168.1.2, use the X-Forwarded-For
|
||||||
// header to deduce the original client IP from the trust-
|
// header to deduce the original client IP from the trust-
|
||||||
// worthy parts of that header.
|
// worthy parts of that header.
|
||||||
// Otherwise, simply return the direct client IP
|
// Otherwise, simply return the direct client IP
|
||||||
fmt.Printf("ClientIP: %s\n", c.ClientIP())
|
fmt.Printf("ClientIP: %s\n", c.ClientIP())
|
||||||
})
|
})
|
||||||
router.Run()
|
router.Run()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user