import "github.com/gin-gonic/gin" func main() { r := gin.Default() r.GET("/", func(c *gin.Context) { clientIP := c.ClientIP() c.JSON(200, gin.H{ "ip": clientIP, }) }) r.Run() }In the code above, we create a new gin router and register a GET handler for the root endpoint "/". Inside the handler function, we call Context.ClientIP() method to retrieve the client's IP address and return it as a JSON response. This example demonstrates how to use the gin.Context package to extract the client IP address from the request headers.