added response format negotiation, api-middleware should be backwards compatible because it defaults to JSON.