I am building a Go service that communicates with multiple third-party providers. This go-service act as an interface between these multiple providers and my internal applications consumes just one API from Go.
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
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 exactly do we structure API response/request structs in Go?
-
Whats the best practice to be followed?
-
Is dto a right approach?
Aucun commentaire:
Enregistrer un commentaire