aboutsummaryrefslogtreecommitdiff
path: root/request/request.go
diff options
context:
space:
mode:
Diffstat (limited to 'request/request.go')
-rw-r--r--request/request.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/request/request.go b/request/request.go
index 88a92405f..36ec85731 100644
--- a/request/request.go
+++ b/request/request.go
@@ -59,6 +59,15 @@ func (r *Request) IP() string {
return r.ip
}
+// LocalIP gets the (local) IP address of server handling the request.
+func (r *Request) LocalIP() string {
+ ip, _, err := net.SplitHostPort(r.W.LocalAddr().String())
+ if err != nil {
+ return r.W.LocalAddr().String()
+ }
+ return ip
+}
+
// Port gets the (remote) port of the client making the request.
func (r *Request) Port() string {
if r.port != "" {