(key string)
| 189 | } |
| 190 | |
| 191 | func (r *RPCInvocation) GetAttachment(key string) (string, bool) { |
| 192 | r.lock.RLock() |
| 193 | defer r.lock.RUnlock() |
| 194 | if r.attachments == nil { |
| 195 | return "", false |
| 196 | } |
| 197 | if value, existed := r.attachments[key]; existed { |
| 198 | if str, strOK := value.(string); strOK { |
| 199 | return str, true |
| 200 | } else if strArr, strArrOK := value.([]string); strArrOK && len(strArr) > 0 { |
| 201 | // For triple protocol, the attachment value is wrapped by an array. |
| 202 | return strArr[0], true |
| 203 | } |
| 204 | } |
| 205 | return "", false |
| 206 | } |
| 207 | |
| 208 | func (r *RPCInvocation) GetAttachmentWithDefaultValue(key string, defaultValue string) string { |
| 209 | if value, ok := r.GetAttachment(key); ok { |
no outgoing calls
no test coverage detected