ThreeDotsLabs / wild-workouts-go-ddd-example

Go DDD example application. Complete project to show how to apply DDD, Clean Architecture, and CQRS by practical refactoring.
https://threedots.tech
MIT License
5.04k stars 464 forks source link

Wrapper for pure GET without any parameters #72

Open suntong opened 9 months ago

suntong commented 9 months ago

How should I write a Handler wrapper for pure GET operation that has no any parameters?

All Handler wrappers seems to need to wrap onto something, of what the user is requesting:

https://github.com/ThreeDotsLabs/wild-workouts-go-ddd-example/blob/56ef6d5daa2e1f2de82f85278eef1fe5825eb401/internal/trainings/app/command/schedule_training.go#L24

Then passes on such user requests to the Handler in the end.

However, for a pure GET operation that has no any parameters, like /health that I need to return CPU & Mem info, how should I write a Handler wrapper for it please?

ronnieholm commented 9 months ago

One could make the argument that implementing a health check endpoint isn't the responsibility of application core. It isn't a business requirement. Health checks belong in the infrastructure layer. It shouldn't go through a command or query.

suntong commented 9 months ago

Fine. but I do have application core that do not need any parameters at all though. The health check is just an example that I don't need more explanation and people would understand. I do have application core that are like that, no any parameters.