Saturday, June 30, 2018

Using Fractal as Your OpenWhisk API's View Layer

When writing an API, it's common to produce an output that conforms to a known media type such as JSON API or HAL. I'm a strong believer that even though I'm writing an API, my application has a view layer. It's not the same as building an HTML page, but you still need to separate out the code that creates the structured output from your model layer. For a couple of APIs that I've written recently, I've used Fractal for this.

Using Fractal

To use Fractal, you need some data. This can be a single entity or a list of entities. You then put your entity into Fractal Item or your list into a Collection and then transform it.



from DZone.com Feed https://ift.tt/2KzKpn7

No comments:

Post a Comment