contributte / apitte

:wrench: An opinionated and enjoyable API framework based on Nette Framework. Supporting content negotiation, debugging, middlewares, attributes, annotations and loving openapi/swagger.

Home Page:https://contributte.org/packages/contributte/apitte/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple response decoration

tprochazka opened this issue · comments

I'm migrating my app from using great Drahak\Restful, because this library is sadly not maintained.
It is based directly on Nette presenters, which is also somehow supported by Apitte, but deprecated.
So I'm trying to avoid it. But I miss Nette presenter's life-cycle. I mean that it calls some method before and some method after the main method generating content.

So I can simply do some common preparation in one place, then execute requested action, which just prepares data as array() structure. And then again in one place add some additional data, convert it to JSON, and put it into some envelope. In Appite itis probably possible by some request/response decorators, but it is too general. Is any way how to do it only on one class level? Like, create a decorator that will actually look for some method inside of the source Controller?

Or should I switch to use https://github.com/apitte/presenter ?

Hi. Thanks for the issue.

Apitte is useful for API-driven application. If you need good API solution, pick Apitte. If you need some routes returning JSON, maybe is simpler to use nette presenter with sendJson($data).