Commit 00436dd2 authored by Jeromy's avatar Jeromy

add a bit more type checking

parent 458c45db
......@@ -85,6 +85,11 @@ func MakeTypedEncoder(f interface{}) func(*Request) func(io.Writer) Encoder {
panic("MakeTypedEncoder must return an error")
}
writerInt := reflect.TypeOf((*io.Writer)(nil)).Elem()
if t.In(0) != reflect.TypeOf(&Request{}) || !t.In(1).Implements(writerInt) {
panic("MakeTypedEncoder must receive a function matching func(*Request, io.Writer, ...)")
}
valType := t.In(2)
return MakeEncoder(func(req *Request, w io.Writer, i interface{}) error {
......
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