Coder Social home page Coder Social logo

Comments (6)

laruence avatar laruence commented on May 3, 2024

I think you can do such check in Yaf_Plugin::dispatchLoopStartup, then twist the Yaf_Response into any form you deteced in DispatchLoopShutdown

from yaf.

guilhermeaiolfi avatar guilhermeaiolfi commented on May 3, 2024

That would mean I would had the same data in all forms. I want to fetch the data depending on the output type. It's not just a case of "formatting" the output.

from yaf.

akDeveloper avatar akDeveloper commented on May 3, 2024

@guilhermeaiolfi i think that you need a custom Route.
A custom Route can match a request against http_accept or by url 'extension' ex product/1.xml, product/1.json etc.
So according to request you can tel the Route execute the action you want.
But in most cases a browser sends an http_accept like text/html,application/xhtml+xml,application/xml; so a good solution for browser based applications, not REST API, it is a good practice to play with url 'extension'

from yaf.

zh-ang avatar zh-ang commented on May 3, 2024

@guilhermeaiolfi Another solution:
Make different views for HTML/XML/JSON into different view directories, you could keep default view path as APPLICATION_PATH/views, and create APPLICATION_PATH/views.json/, APPLICATION_PATH/views.xml/ or APPLICATION_PATH/views.mobile/. Then let Plugin to setScriptPath for view on different condition.
Hope it could answer your question.

from yaf.

guilhermeaiolfi avatar guilhermeaiolfi commented on May 3, 2024

@zh-ang: That's the closest I was thinking of. But that would require a lot more files than needed in my case. That's why I was thinking in different method for each output type and not different view/class/files. But I'm confident that it'll be possible and that it'll not be difficult. Thanks everyone for the suggestions.

from yaf.

guilhermeaiolfi avatar guilhermeaiolfi commented on May 3, 2024

Wouldn't it be nice to support this concept in the Yaf core? In a world of backbone, ember, angularjs, knockout and so many others. The server side of things needs to delivery all kinds of data depending on who is requesting. I think that's where web developing is heading.

My case is that my ERP request data using SOAP, I'm creating a web admin panel that uses a REST API, and the regular user/visitor uses plain HTML.

from yaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.