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:
Joram Wilander
2017-01-13 13:53:37 -05:00
committed by GitHub
parent 07bad4d6d5
commit 97558f6a6e
85 changed files with 3368 additions and 2997 deletions

View File

@@ -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
}