zendframework / zend-diactoros

PSR-7 HTTP Message implementation
BSD 3-Clause "New" or "Revised" License
1.55k stars 152 forks source link

Add simple XML Response Ref #189 #285

Closed gsteel closed 6 years ago

Xerkus commented 6 years ago

Why do we have those at all? Those extra response objects do not bring any value. Any dependency must be on interface, so they can't be used for typehinting. Whatever is creating new XML response, or Json response, could just set content type itself, it already knows enough to do so.

Xerkus commented 6 years ago

Test failure is unrelated. IANA published new status code

gsteel commented 6 years ago

Fair enough, but the convenience of not having to repeat yourself whenever you want to return an HTML/Json/Text/XML response is helpful no?

Xerkus commented 6 years ago

I suppose I was too hasty to comment. It certainly saves couple lines of code. You see, there is a PSR-17, HTTP factory interface, that enables consumers not to depend on diactoros at all. On the other hand this little convenience does not really affect interoperability. I can live with it.

weierophinney commented 6 years ago

@Xerkus these convenience response types are primarily for application developers, who are producing request handlers/inner middleware, and who already know the PSR-7 implementation they are choosing. Having these is a differentiator with other implementations, and makes producing common response types simpler. The factories in PSR-17, while generally useful, still make some things convoluted (e.g., producing a JSON response, an HTML or XML response, a redirect, etc.).

PSR-17, in my mind, is more around writing distributable middleware, where you do not want to make any assumptions about which PSR-7 implementation a consumer is using.

weierophinney commented 6 years ago

Thanks, @gsteel!