prooph / event-store-http-api

Prooph EventStore HTTP API
http://getprooph.org/
BSD 3-Clause "New" or "Revised" License
18 stars 3 forks source link

Dynamic response transformers. #3

Closed bweston92 closed 8 years ago

bweston92 commented 8 years ago

- What I did

Added concept of transformers so you can dynamically add transformers depending on accept header.

- How I did it

Added an map (array) for accept header to corresponding transformers.

I was going to have a transformer factory that is injected into the Load action how-ever probably a bit over kill.

So instead the container factory for Load action can be created by a consumer of this package. Or maybe we can add it to configuration.

- How to verify it

Add multiple transformers, for certain your own custom vendor specification or already implemented responses (JsonTransformer). This will then need to be easily added by using your own container factory for Load action. This factory will need to call addTransformer with the new transformer and possible accept headers for it.

- Description for the changelog

prolic commented 8 years ago

I don't know, this might be too much. We could return xml instead of json based on header, and this is really enough imho. You either want xml or json, but we should not provide support for yml and whatever.

bweston92 commented 8 years ago

Ok and what if a company/vendor wants their own format?

Maybe moving from an existing stream API, they could add an ACL though I suppose.

Will leave it with you :)

prolic commented 8 years ago

Acl is already planned.

Am 15.11.2016 00:47 schrieb "Bradley Weston" notifications@github.com:

Ok and what if a company/vendor wants their own format?

Maybe moving from an existing stream API, they could add an ACL though I suppose.

Will leave it with you :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/prooph/event-store-http-api/pull/3#issuecomment-260390194, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYEvCH3cRHYb-jC8MPGcTDmAyoiKP2Dks5q-JCvgaJpZM4KxhAT .

prolic commented 8 years ago

Would say custom format is not needed.

Am 15.11.2016 01:06 schrieb :

Acl is already planned.

Am 15.11.2016 00:47 schrieb "Bradley Weston" notifications@github.com:

Ok and what if a company/vendor wants their own format?

Maybe moving from an existing stream API, they could add an ACL though I suppose.

Will leave it with you :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/prooph/event-store-http-api/pull/3#issuecomment-260390194, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYEvCH3cRHYb-jC8MPGcTDmAyoiKP2Dks5q-JCvgaJpZM4KxhAT .

codeliner commented 8 years ago

A custom transformer can definitely be useful! Even if the user deals with JSON or XML they may need to use a custom transformer because event payload need to be handled in a special way. PHP arrays don't match 1:1 with JSON and XML is even more pain. So +1 for the feature