I am building a Go service that communicates with multiple third-party providers. This go-service acts as an interface between these multiple providers and my internal applications consume just one API from this Go service.
My application has the below structure now
- app
- config
- controllers
- dto
- exceptions
- providers - All external API calls to thrid-party happens here
- services - Business logic
- tests
I would have to integrate to over 10 third-party APIs and I am confused on how to keep the structs for JSON marshal and unmarshalling.
From a maintenance perspective, I keep few things in mind for restructuring the application
-
each third party services can be integrated by a developer independently without getting into one another messing someone else's code. The developer may only necessarily know the integration of his/her third party integration.
-
Each third-party might have some common utils which can be utilized, say for eg: authentication mechanism or logging or things like sentry.
-
Where do I place the structs of request and response of all external API call?
What I was planning was
- dto
- thirdparty1RequestStruct
- thirdparty1ResponseStruct
- thirdparty2RequestStruct
- thirdparty2ResponseStruct ... and so on.
But when I have around 20 third parties APIs, there would be a lot of request-response struct and the directory will be too big from a readability perspective.
My question is
How would you as a go developer go about structuring the application keeping the above requirements in mind?
Please bear with this question as I am pretty new to go programming. Understand that this is opinionated, but for this specific use case how does it work? I couldn't find any resources online.
Aucun commentaire:
Enregistrer un commentaire