WIP: Add health endpoint
What is the purpose of this change? What does it change?
This pull request adds an endpoint named /health. It replies with:
-
200 OKwhen the repository base path is writable and there is some free space left -
500 Internal Server Errorwhen either the path is not writable byrest-server, or the disk is full
This endpoint can be used to monitor the status of a rest-server daemon (for example in k8s / docker)
Was the change discussed in an issue or in the forum before?
Feature was requested and is being discussed here: https://github.com/restic/rest-server/issues/147
Checklist
- [X] I have enabled maintainer edits for this PR
- [ ] I have added tests for all changes in this PR
- [ ] I have added documentation for the changes (in the manual)
- [ ] There's a new file in
changelog/unreleased/that describes the changes for our users (template here) - [ ] I have run
gofmton the code in all commits - [X] All commit messages are formatted in the same style as the other commits in the repo
- [ ] I'm done, this Pull Request is ready for review
I added the external library https://github.com/itchio/ox . That library contains wrappers for many Windows syscall. I used some of them to get information about the repository path write permission for current user.
I had to call a Windows API directly, however I already made a pull request to the original library to add that wrapper.
I've tested the code on Windows and Linux.
Do I need to write some tests for this? If so, do you have any suggestion? Testing permissions and free space might be difficult...