6
6
"encoding/json"
7
7
"encoding/xml"
8
8
"fmt"
9
- "github.com/abbot/go-http-auth"
10
9
"io"
11
10
"io/ioutil"
12
11
"log"
@@ -20,6 +19,7 @@ import (
20
19
"sync/atomic"
21
20
"time"
22
21
22
+ "github.com/abbot/go-http-auth"
23
23
. "github.com/aerokube/ggr/config"
24
24
"golang.org/x/net/websocket"
25
25
)
@@ -61,10 +61,12 @@ var keys = struct {
61
61
desiredCapabilities string
62
62
w3cCapabilities string
63
63
alwaysMatch string
64
+ firstMatch string
64
65
}{
65
66
desiredCapabilities : "desiredCapabilities" ,
66
67
w3cCapabilities : "capabilities" ,
67
68
alwaysMatch : "alwaysMatch" ,
69
+ firstMatch : "firstMatch" ,
68
70
}
69
71
70
72
var (
@@ -95,13 +97,23 @@ func (c caps) capabilities(fn func(m map[string]interface{}, w3c bool, extension
95
97
}
96
98
if w3cCapabilities , ok := c [keys .w3cCapabilities ]; ok {
97
99
if m , ok := w3cCapabilities .(map [string ]interface {}); ok {
100
+ var match map [string ]interface {}
98
101
if alwaysMatch , ok := m [keys .alwaysMatch ]; ok {
99
102
if m , ok := alwaysMatch .(map [string ]interface {}); ok {
100
- fn (m , true , false )
101
- for k , v := range m { // Extension capabilities have ":" in key
102
- if ec , ok := v .(map [string ]interface {}); ok && strings .Contains (k , ":" ) {
103
- fn (ec , true , true )
104
- }
103
+ match = m
104
+ }
105
+ } else if firstMatch , ok := m [keys .firstMatch ]; ok {
106
+ if m , ok := firstMatch .([]interface {}); ok && len (m ) > 0 {
107
+ if m , ok := m [0 ].(map [string ]interface {}); ok {
108
+ match = m
109
+ }
110
+ }
111
+ }
112
+ if match != nil {
113
+ fn (match , true , false )
114
+ for k , v := range m { // Extension capabilities have ":" in key
115
+ if ec , ok := v .(map [string ]interface {}); ok && strings .Contains (k , ":" ) {
116
+ fn (ec , true , true )
105
117
}
106
118
}
107
119
}
0 commit comments