DE-3247 | updated logging for failing requests

This commit is contained in:
puru
2024-08-26 16:49:15 +05:30
parent 497b7db262
commit dae6a7c324
3 changed files with 20 additions and 2 deletions

View File

@@ -1,7 +1,24 @@
package utils
import "time"
import (
"net"
"strings"
"time"
)
func NanosToMillis(timestamp int64) int64 {
return timestamp * (int64(time.Nanosecond) / int64(time.Millisecond))
}
func GetClientIP(xForwardedFor string, remoteAddr string) string {
if xForwardedFor != "" {
ips := strings.Split(xForwardedFor, ",")
return strings.TrimSpace(ips[0])
}
ip, _, err := net.SplitHostPort(remoteAddr)
if err != nil {
return remoteAddr
}
return ip
}