Move domain logic from middleware to JsonSchema#addHeaders method.