You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The oapi-codegen based petstore example has a very simple and straightforward file structure. Using the fiber server as an example, as far as the server end is concerned, here are all the files it needs:
However in file domain/petstore.go (changed a bit from here):
// FindPets implements all the handlers in the ServerInterfacefunc (p*PetStore) FindPets(c*fiber.Ctx, params ports.FindPetsParams) error {
I.e., I have to use the type FindPetsParams defined in ports (ports/petstore-types.gen.go) in domain, and then extract the server agnostic part of algorithm into function FindPets in the domain package, and call such domain FindPets function in http.go file within the ports package.
In other words, I'll be doing import cycling, which is not allowed in Go. So, all in all,
How to re-arrange oapi-codegen based petstore example using the Repository Pattern? thx.
The text was updated successfully, but these errors were encountered:
First of all, your domain should have no relation to fiber, since it's a http-specific library. Keep fiber imports in ports and nowhere else.
Then, you need to define the Params inside domain and map between it and fiber's Params in ports. Or you can have domain constructors that take arguments and just pass them from Params.
The oapi-codegen based petstore example has a very simple and straightforward file structure. Using the fiber server as an example, as far as the server end is concerned, here are all the files it needs:
How to re-arrange oapi-codegen based petstore example using the Repository Pattern?
I tried to split the code as per the Repository Pattern myself following the folder structure in #69:
However in file
domain/petstore.go
(changed a bit from here):I.e., I have to use the type
FindPetsParams
defined inports
(ports/petstore-types.gen.go
) in domain, and then extract the server agnostic part of algorithm into functionFindPets
in the domain package, and call such domainFindPets
function inhttp.go
file within theports
package.In other words, I'll be doing import cycling, which is not allowed in Go. So, all in all,
How to re-arrange oapi-codegen based petstore example using the Repository Pattern? thx.
The text was updated successfully, but these errors were encountered: