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