thephpleague / route

Fast PSR-7 based routing and dispatch component including PSR-15 middleware, built on top of FastRoute.
http://route.thephpleague.com
MIT License
651 stars 126 forks source link

Allow custom content-type with JSON strategy #202

Closed shadowhand closed 6 years ago

shadowhand commented 6 years ago

Fixes #201

philipobenito commented 6 years ago

This is a great idea, I’d like us to go a little more generic on it though and make the behaviour available on all strategies, maybe in an abstract.

I think we should go with setDefaultResponseHeaders and addDefaultResponseHeader, set should loop a key => value array and invoke add, add should add to a protected property array, overriding anything that already exists.

JsonStrategy should have a default content type already in the array. Then once we have a response, loop through the array and add each header if the response doesn’t already have it.

Thoughts?

shadowhand commented 6 years ago

Replaced with #211