03-27-2015, 04:17 AM
Hey guys,
i could need some advice.
I've an extensive application (200+ Models)
Lately we got more and more a situation where we need to output the content in different Types (XML, JSON, HTML, CSV, PDF and so on).
Our solution till now is like the following:
Extend the affected controller with a function json (e.g. for a json request) -> pick up the data from the model and send the data back
An Url looks like: /news/list/json or /news/list/xml and so on.
In this situation you can decide what you want.
The big downside is the redundancy - always put a function json in the controller method and so on.
My idea now is, to create a service like REST but with more options - which means i need to react based on the clients request.
This means, i need different base view folders like (views/xml/ etc.)
I don't think i have a problem to accomplish this from a technical point of view (extending the loader class and so on)
But does anybody know a fool proof method to determine such a request (maybe via content-type headers ?) or is my idea totally nuts ?
Or are there any other solutions around ?
thx in advance for your answers
i could need some advice.
I've an extensive application (200+ Models)
Lately we got more and more a situation where we need to output the content in different Types (XML, JSON, HTML, CSV, PDF and so on).
Our solution till now is like the following:
Extend the affected controller with a function json (e.g. for a json request) -> pick up the data from the model and send the data back
An Url looks like: /news/list/json or /news/list/xml and so on.
In this situation you can decide what you want.
The big downside is the redundancy - always put a function json in the controller method and so on.
My idea now is, to create a service like REST but with more options - which means i need to react based on the clients request.
This means, i need different base view folders like (views/xml/ etc.)
I don't think i have a problem to accomplish this from a technical point of view (extending the loader class and so on)
But does anybody know a fool proof method to determine such a request (maybe via content-type headers ?) or is my idea totally nuts ?

Or are there any other solutions around ?
thx in advance for your answers