how to structure this project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to structure this project

r/ Wobben
Hello,

I'm trying to build a site where the data is pulled out of a external json api.

Now I have 1 question.

Where do I do the fetching and parsing of the json. In the handler or schould I write seperate functions for it that the handler uses ?

Roelof

--
Reply | Threaded
Open this post in threaded view
|

Re: how to structure this project

Alp Mestanogullari
I definitely recommend separate functions. I've always had a harder time working on services where the code for the handlers got long and was doing several things, as opposed to hust delegating the few steps to a few well thought out functions.

Le 13 févr. 2017 18:09, "r/ Wobben" <[hidden email]> a écrit :
Hello,

I'm trying to build a site where the data is pulled out of a external json api.

Now I have 1 question.

Where do I do the fetching and parsing of the json. In the handler or schould I write seperate functions for it that the handler uses ?

Roelof

--

--
Reply | Threaded
Open this post in threaded view
|

Re: how to structure this project

r/ Wobben
Alp,

Thanks,

So something like this :

type PaintingAPI = "paintings" :> read_all_json() 

where read_all_json is a function which make a request to the api and parse it to a [] ?









Op maandag 13 februari 2017 19:22:58 UTC+1 schreef Alp Mestanogullari:
I definitely recommend separate functions. I've always had a harder time working on services where the code for the handlers got long and was doing several things, as opposed to hust delegating the few steps to a few well thought out functions.

Le 13 févr. 2017 18:09, "r/ Wobben" <<a onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;" href="javascript:" target="_blank" rel="nofollow" gdf-obfuscated-mailto="umioCTofCwAJ">wobb...@...> a écrit :
Hello,

I'm trying to build a site where the data is pulled out of a external json api.

Now I have 1 question.

Where do I do the fetching and parsing of the json. In the handler or schould I write seperate functions for it that the handler uses ?

Roelof

--

--
Reply | Threaded
Open this post in threaded view
|

Re: how to structure this project

r/ Wobben


Op maandag 13 februari 2017 19:37:16 UTC+1 schreef r/ Wobben:
Alp,

Thanks,

So something like this :

type PaintingAPI = "paintings" :> read_all_json() 

where read_all_json is a function which make a request to the api and parse it to a [] ?

I saw that I have to make 3 seperate calls to the api to get all the data.  









Op maandag 13 februari 2017 19:22:58 UTC+1 schreef Alp Mestanogullari:
I definitely recommend separate functions. I've always had a harder time working on services where the code for the handlers got long and was doing several things, as opposed to hust delegating the few steps to a few well thought out functions.

Le 13 févr. 2017 18:09, "r/ Wobben" <[hidden email]> a écrit :
Hello,

I'm trying to build a site where the data is pulled out of a external json api.

Now I have 1 question.

Where do I do the fetching and parsing of the json. In the handler or schould I write seperate functions for it that the handler uses ?

Roelof

--

--