RealIP returns the client IP address using the configured extraction strategy. If Echo#IPExtractor is set, it is used to resolve the client IP from the incoming request (typically via proxy headers such as X-Forwarded-For or X-Real-IP). Look into the `ip.go` file for comments and examples. See: -
()
| 247 | // - No validation or trust enforcement is performed unless implemented by the configured IPExtractor. |
| 248 | // - When relying on proxy headers, ensure the application is deployed behind trusted intermediaries to avoid spoofing. |
| 249 | func (c *Context) RealIP() string { |
| 250 | if c.echo != nil && c.echo.IPExtractor != nil { |
| 251 | return c.echo.IPExtractor(c.request) |
| 252 | } |
| 253 | // req.RemoteAddr is the IP address of the remote end of the connection, which may be a proxy. It is populated by the |
| 254 | // http.conn.readRequest() method and uses net.Conn.RemoteAddr().String() which we trust. |
| 255 | ra, _, _ := net.SplitHostPort(c.request.RemoteAddr) |
| 256 | return ra |
| 257 | } |
| 258 | |
| 259 | // Path returns the registered path for the handler. |
| 260 | func (c *Context) Path() string { |
no outgoing calls