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

commands: Made Request#Option also return an existence bool

parent 4f06c6fd
......@@ -21,8 +21,9 @@ func (r *Request) SetPath(path []string) {
r.path = path
}
func (r *Request) Option(name string) interface{} {
return r.options[name]
func (r *Request) Option(name string) (interface{}, bool) {
val, ok := r.options[name]
return val, ok
}
func (r *Request) SetOption(name string, value interface{}) {
......
......@@ -57,8 +57,8 @@ func (r *Response) Marshal() ([]byte, error) {
return nil, fmt.Errorf("No error or value set, there is nothing to marshal")
}
enc := r.req.Option("enc")
if enc == nil {
enc, ok := r.req.Option("enc")
if !ok || enc.(string) == "" {
return nil, fmt.Errorf("No encoding type was specified")
}
encType := EncodingType(strings.ToLower(enc.(string)))
......
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