Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET /health #40

Merged
merged 9 commits into from
Sep 30, 2024
Merged

GET /health #40

merged 9 commits into from
Sep 30, 2024

Conversation

benjaspet
Copy link
Collaborator

@benjaspet benjaspet commented Sep 30, 2024

Description

Link to Issue

This pull request features a simple GET /health endpoint to monitor the backend's API health. Backend health checks are a good practice because they allow us to properly monitor anything that could prevent our API from servicing incoming requests in the way that it should.

How Has This Been Tested?

This has been testing using Postman and a simple unit test I wrote:

t.Run("GetHealth", func(t *testing.T) {

	resp, err := http.Get("http://localhost:8080/health")
	if err != nil {
		log.Fatalln(err)
	}

	if err != nil {
		t.Errorf("expected no error, got %v", err)
	}

	if resp.StatusCode != http.StatusOK {
		t.Errorf("expected status 200, got %d", resp.StatusCode)
	}

})

Note that I removed this test temporarily to pass GH Actions tests that could not run the backend in parallel.

Checklist

  • I have performed a self-review of my code
  • I have reached out to another developer to review my code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

@benjaspet benjaspet mentioned this pull request Sep 30, 2024
@garrettladley garrettladley merged commit 58aa709 into main Sep 30, 2024
3 checks passed
@garrettladley garrettladley deleted the backend/crud-health branch September 30, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants