summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-07-02 12:05:26 +0300
committerValery Piashchynski <[email protected]>2021-07-02 12:05:26 +0300
commite4834e08dcf5885623091bbe5e7e75e7950a07f3 (patch)
tree808bd42e9e665f73ced438161b6869b08f14d4cc /plugins
parenta4b9d0c47494431c30f357c3616e53baf411360f (diff)
- joinTopics/Server as constants, do not allocate strings on every
request Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/websockets/validator/access_validator.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/websockets/validator/access_validator.go b/plugins/websockets/validator/access_validator.go
index e666f846..2685da7f 100644
--- a/plugins/websockets/validator/access_validator.go
+++ b/plugins/websockets/validator/access_validator.go
@@ -12,6 +12,11 @@ import (
type AccessValidatorFn = func(r *http.Request, channels ...string) (*AccessValidator, error)
+const (
+ joinServer string = "ws:joinServer"
+ joinTopics string = "ws:joinTopics"
+)
+
type AccessValidator struct {
Header http.Header `json:"headers"`
Status int `json:"status"`
@@ -26,7 +31,7 @@ func ServerAccessValidator(r *http.Request) ([]byte, error) {
return nil, errors.E(op, err)
}
- defer delete(attributes.All(r), "ws:joinServer")
+ defer delete(attributes.All(r), joinServer)
req := &handler.Request{
RemoteAddr: handler.FetchIP(r.RemoteAddr),
@@ -54,7 +59,7 @@ func TopicsAccessValidator(r *http.Request, topics ...string) ([]byte, error) {
return nil, errors.E(op, err)
}
- defer delete(attributes.All(r), "ws:joinTopics")
+ defer delete(attributes.All(r), joinTopics)
req := &handler.Request{
RemoteAddr: handler.FetchIP(r.RemoteAddr),