0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-01-06 22:40:31 -05:00

templates: Changed .RemoteAddr to .IP and stripped port

This commit is contained in:
Matthew Holt 2015-05-05 15:49:22 -06:00
parent 21c26f48d0
commit a9064a7871

View file

@ -51,9 +51,13 @@ func (c context) Header(name string) string {
return c.req.Header.Get(name)
}
// RemoteAddr gets the address of the client making the request.
func (c context) RemoteAddr() string {
return c.req.RemoteAddr
// IP gets the (remote) IP address of the client making the request.
func (c context) IP() string {
ip, _, err := net.SplitHostPort(c.req.RemoteAddr)
if err != nil {
return c.req.RemoteAddr
}
return ip
}
// URI returns the raw, unprocessed request URI (including query