mirror of
https://github.com/coredns/coredns.git
synced 2025-10-26 15:54:16 -04:00
plugin/rewrite: use request.Request and other cleanups (#1920)
This was done anyway, but only deep in the functions, just do this everywhere; allows for shorter code and request.Request allows for caching as well. Cleanups, make it more Go like. * remove unneeded switches * remove testdir (why was this there??) * simplify the logic * remove unneeded variables * put short functions on a single line * fix documentation. * spin off wire funcs in wire.go, make them functions. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user