Added rewrite middleware and one method.

The tags here are the same as what `json.Marshal` would do by default if you left the fields untagged. Tagging them brings attention to the fact that this struct is intended for json Marshaling, though, so I don't think you should drop them.