diff options
author | Valery Piashchynski <[email protected]> | 2021-05-31 16:05:00 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-31 16:05:00 +0300 |
commit | 49703d70a3ede70ce9a0cab824cbcb96dbf824c0 (patch) | |
tree | 181d72a3321d52c960a519ba3a233e3e7fe8e86a /pkg | |
parent | 0ee91dc24d3e68706d89092c06b1c0d09dab0353 (diff) |
- Rework access_validators
- WS plugin uses it's own pool to handle requests on the /ws (or any
user-defined) endpoint
- Ability to write custom validators
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/pubsub/message.go | 6 | ||||
-rw-r--r-- | pkg/worker_handler/handler.go | 6 | ||||
-rw-r--r-- | pkg/worker_handler/request.go | 10 |
3 files changed, 11 insertions, 11 deletions
diff --git a/pkg/pubsub/message.go b/pkg/pubsub/message.go index c1a7246a..c17d153b 100644 --- a/pkg/pubsub/message.go +++ b/pkg/pubsub/message.go @@ -5,15 +5,15 @@ import ( ) type Message struct { - // Topic message been pushed into. - Topics []string `json:"topic"` - // Command (join, leave, headers) Command string `json:"command"` // Broker (redis, memory) Broker string `json:"broker"` + // Topic message been pushed into. + Topics []string `json:"topic"` + // Payload to be broadcasted Payload []byte `json:"payload"` } 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() } |