RemoteAddr
获取请求客户端的IP,直接获取连接的客户端,不会从请求头中获取。
Example
package main
import (
"log"
"github.com/vicanso/elton"
"github.com/vicanso/elton/middleware"
)
func main() {
e := elton.New()
e.Use(middleware.NewDefaultResponder())
e.GET("/", func(c *elton.Context) (err error) {
log.Println(c.RemoteAddr())
c.Body = "Hello, World!"
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}