summaryrefslogtreecommitdiff
path: root/pkg/worker_handler
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/worker_handler')
-rw-r--r--pkg/worker_handler/handler.go6
-rw-r--r--pkg/worker_handler/request.go10
2 files changed, 8 insertions, 8 deletions
diff --git a/pkg/worker_handler/handler.go b/pkg/worker_handler/handler.go
index d98cdef0..e0d1aae0 100644
--- a/pkg/worker_handler/handler.go
+++ b/pkg/worker_handler/handler.go
@@ -202,16 +202,16 @@ func (h *Handler) resolveIP(r *Request) {
// CF-Connecting-IP is an Enterprise feature and we check it last in order.
// This operations are near O(1) because Headers struct are the map type -> type MIMEHeader map[string][]string
if r.Header.Get("X-Real-Ip") != "" {
- r.RemoteAddr = fetchIP(r.Header.Get("X-Real-Ip"))
+ r.RemoteAddr = FetchIP(r.Header.Get("X-Real-Ip"))
return
}
if r.Header.Get("True-Client-IP") != "" {
- r.RemoteAddr = fetchIP(r.Header.Get("True-Client-IP"))
+ r.RemoteAddr = FetchIP(r.Header.Get("True-Client-IP"))
return
}
if r.Header.Get("CF-Connecting-IP") != "" {
- r.RemoteAddr = fetchIP(r.Header.Get("CF-Connecting-IP"))
+ r.RemoteAddr = FetchIP(r.Header.Get("CF-Connecting-IP"))
}
}
diff --git a/pkg/worker_handler/request.go b/pkg/worker_handler/request.go
index 178bc827..75ee8381 100644
--- a/pkg/worker_handler/request.go
+++ b/pkg/worker_handler/request.go
@@ -61,7 +61,7 @@ type Request struct {
body interface{}
}
-func fetchIP(pair string) string {
+func FetchIP(pair string) string {
if !strings.ContainsRune(pair, ':') {
return pair
}
@@ -73,10 +73,10 @@ func fetchIP(pair string) string {
// NewRequest creates new PSR7 compatible request using net/http request.
func NewRequest(r *http.Request, cfg config.Uploads) (*Request, error) {
req := &Request{
- RemoteAddr: fetchIP(r.RemoteAddr),
+ RemoteAddr: FetchIP(r.RemoteAddr),
Protocol: r.Proto,
Method: r.Method,
- URI: uri(r),
+ URI: URI(r),
Header: r.Header,
Cookies: make(map[string]string),
RawQuery: r.URL.RawQuery,
@@ -174,8 +174,8 @@ func (r *Request) contentType() int {
return contentStream
}
-// uri fetches full uri from request in a form of string (including https scheme if TLS connection is enabled).
-func uri(r *http.Request) string {
+// URI fetches full uri from request in a form of string (including https scheme if TLS connection is enabled).
+func URI(r *http.Request) string {
if r.URL.Host != "" {
return r.URL.String()
}