golang-cafe / job-board

Golang Cafe - Go job board with no recruiters and clear salary ranges
https://golang.cafe
BSD 3-Clause "New" or "Revised" License
208 stars 50 forks source link

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

Open ghost opened 2 years ago

ghost commented 2 years ago

related to #19 #12

congthang12312 commented 1 year ago

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 repoand handlerinside 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
ghost commented 1 year ago

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