Commit 33ad56e6 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands: Safer type coercion when choosing marshaller

parent 0149f65c
......@@ -120,11 +120,12 @@ func (r *response) Marshal() ([]byte, error) {
return []byte{}, nil
}
enc, ok := r.req.Option(EncShort)
if !ok || enc.(string) == "" {
enc, found := r.req.Option(EncShort)
encStr, ok := enc.(string)
if !found || !ok || encStr == "" {
return nil, fmt.Errorf("No encoding type was specified")
}
encType := EncodingType(strings.ToLower(enc.(string)))
encType := EncodingType(strings.ToLower(encStr))
marshaller, ok := marshallers[encType]
if !ok {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment