Instance Method
beforeEncode()
Called before this
Content is encoded, generally for a Response object.mutating func beforeEncode() throws
Discussion
You should use this method to perform any “sanitizing” which you need on the data. For example, you may wish to replace empty strings with a nil, trim() your strings or replace empty arrays with nil. You can also use this method to abort the encoding if something isn’t valid. An empty array may indicate an error, for example.