RLSKey builds the RLS keys to be used for the given request, identified by the request path and the request headers stored in metadata.
(md metadata.MD, host, path string)
| 120 | // RLSKey builds the RLS keys to be used for the given request, identified by |
| 121 | // the request path and the request headers stored in metadata. |
| 122 | func (bm BuilderMap) RLSKey(md metadata.MD, host, path string) KeyMap { |
| 123 | // The path passed in is of the form "/service/method". The keyBuilderMap is |
| 124 | // indexed with keys of the form "/service/" or "/service/method". The service |
| 125 | // that we set in the keyMap (to be sent out in the RLS request) should not |
| 126 | // include any slashes though. |
| 127 | i := strings.LastIndex(path, "/") |
| 128 | service, method := path[:i+1], path[i+1:] |
| 129 | b, ok := bm[path] |
| 130 | if !ok { |
| 131 | b, ok = bm[service] |
| 132 | if !ok { |
| 133 | return KeyMap{} |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | kvMap := b.buildHeaderKeys(md) |
| 138 | if b.hostKey != "" { |
| 139 | kvMap[b.hostKey] = host |
| 140 | } |
| 141 | if b.serviceKey != "" { |
| 142 | kvMap[b.serviceKey] = strings.Trim(service, "/") |
| 143 | } |
| 144 | if b.methodKey != "" { |
| 145 | kvMap[b.methodKey] = method |
| 146 | } |
| 147 | for k, v := range b.constantKeys { |
| 148 | kvMap[k] = v |
| 149 | } |
| 150 | return KeyMap{Map: kvMap, Str: mapToString(kvMap)} |
| 151 | } |
| 152 | |
| 153 | // Equal reports whether bm and am represent equivalent BuilderMaps. |
| 154 | func (bm BuilderMap) Equal(am BuilderMap) bool { |