This commit is contained in:
kevin
2020-07-29 18:00:04 +08:00
parent 121323b8c3
commit ca3934582a
58 changed files with 222 additions and 200 deletions

14
ngin/internal/util.go Normal file
View File

@@ -0,0 +1,14 @@
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
}