Files
go-zero/rest/internal/util.go
2020-07-31 11:14:48 +08:00

15 lines
257 B
Go

package internal
import "net/http"
const xForwardFor = "X-Forward-For"
// Returns the peer address, supports X-Forward-For
func GetRemoteAddr(r *http.Request) string {
v := r.Header.Get(xForwardFor)
if len(v) > 0 {
return v
}
return r.RemoteAddr
}