Skip to content

Commit

Permalink
Preparing for database integration, along with setting it for proper …
Browse files Browse the repository at this point in the history
…practices needed for health checks
  • Loading branch information
Bioblaze committed Oct 12, 2024
1 parent ce8457f commit dc88609
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
TestResults-*
TestResults-*
.env
*.env
*.env.*
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ func main() {
http.ServeFile(w, r, "./static/index.html")
})

r.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
// Set the content type to application/json
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)

// Define a health check response structure
response := map[string]string{"status": "healthy"}

// Encode the response as JSON and send it
json.NewEncoder(w).Encode(response)
})

// Serve all static files from the "static" directory
staticFileDirectory := http.Dir("./static")
staticFileHandler := http.StripPrefix("/static/", http.FileServer(staticFileDirectory))
Expand Down

0 comments on commit dc88609

Please sign in to comment.