mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-4938 Add app package and move logic over from api package (#4931)
* Add app package and move logic over from api package * Change app package functions to return errors * Move non-api tests into app package * Fix merge
This commit is contained in:
@@ -4,7 +4,11 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/mattermost/platform/model"
|
||||
)
|
||||
|
||||
func StringArrayIntersection(arr1, arr2 []string) []string {
|
||||
@@ -48,3 +52,17 @@ func RemoveDuplicatesFromStringArray(arr []string) []string {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func GetIpAddress(r *http.Request) string {
|
||||
address := r.Header.Get(model.HEADER_FORWARDED)
|
||||
|
||||
if len(address) == 0 {
|
||||
address = r.Header.Get(model.HEADER_REAL_IP)
|
||||
}
|
||||
|
||||
if len(address) == 0 {
|
||||
address, _, _ = net.SplitHostPort(r.RemoteAddr)
|
||||
}
|
||||
|
||||
return address
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user