job-board icon indicating copy to clipboard operation
job-board copied to clipboard

[DX] split handlers.go into domain specific handlers ie. company/handlers.go, job/handlers.go etc

Open ghost opened this issue 3 years ago • 2 comments

related to #19 #12

ghost avatar Feb 22 '22 22:02 ghost

I'm not sure about applying the split handler in your project. It will be a lifecycle import. server.go using company/repository.go for do something ->So server.go need to import internal/company company/handler.go using server.go -> So company/handler.go need to import internal/server =>error lifecycle import will appear if you want to change to structure project. Because of server.go quite not good, server.go uses another repository. But repo and handler inside 1 pkg for structure:

internal\
   company\
       handler.go (import server pkg)
       repository.go
   server\
       server.go (import company pkg)
===> error lifecycle import

I suggest you like this

internal\
   handler\
       company.go 
       developer.go
       ....
   server\
       server.go (import company pkg)
===> working

congthang12312 avatar Apr 22 '23 09:04 congthang12312

i think it's too much work to restructure all the folders, we could just add subfolders for each domain entity

/company
  /handlers
    handler.go
  /repositories
    repository.go
  /models
    model.go

ghost avatar Apr 24 '23 11:04 ghost