Handle encoding/coercing/validation in the encoder

Rather than having the dispatcher coerce and validate responses or
handle that in a separate middleware, move it all into the encoder.