From a9064a787135571812729a1f645c3175fe4a45de Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 5 May 2015 15:49:22 -0600 Subject: [PATCH] templates: Changed .RemoteAddr to .IP and stripped port --- middleware/templates/context.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/middleware/templates/context.go b/middleware/templates/context.go index a0dfc663..bdecea8b 100644 --- a/middleware/templates/context.go +++ b/middleware/templates/context.go @@ -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