(w http.ResponseWriter, kv *KV, msg Message, format string)
| 167 | } |
| 168 | |
| 169 | func viewMessage(w http.ResponseWriter, kv *KV, msg Message, format string) { |
| 170 | c := kv.GetCodec(msg.Pair.Codec) |
| 171 | if c == nil { |
| 172 | http.Error(w, "codec not found", http.StatusNotFound) |
| 173 | return |
| 174 | } |
| 175 | |
| 176 | val, err := c.Decode(msg.Pair.Value) |
| 177 | if err != nil { |
| 178 | http.Error(w, fmt.Sprintf("failed to decode: %v", err), http.StatusInternalServerError) |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | formatValue(w, val, format) |
| 183 | } |
| 184 | |
| 185 | func viewKey(w http.ResponseWriter, store map[string]ValueDesc, key string, format string) { |
| 186 | if store[key].value == nil { |
no test coverage detected