-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
) | ||
|
||
type HealthResponse struct { | ||
Status string `json:"status"` | ||
Message string `json:"message"` | ||
} | ||
|
||
func main() { | ||
http.HandleFunc("/api/v1/health1", health1Handler) | ||
http.HandleFunc("/api/v1/health2", health2Handler) | ||
http.HandleFunc("/api/v1/health3", health3Handler) | ||
http.HandleFunc("/api/v1/health4", health4Handler) | ||
|
||
http.ListenAndServe(":8080", nil) | ||
} | ||
|
||
func health1Handler(w http.ResponseWriter, r *http.Request) { | ||
response := HealthResponse{Status: "ok", Message: "Service 1 is healthy"} | ||
json.NewEncoder(w).Encode(response) | ||
} | ||
|
||
func health2Handler(w http.ResponseWriter, r *http.Request) { | ||
response := HealthResponse{Status: "ok", Message: "Service 2 is healthy"} | ||
json.NewEncoder(w).Encode(response) | ||
} | ||
|
||
func health3Handler(w http.ResponseWriter, r *http.Request) { | ||
response := HealthResponse{Status: "ok", Message: "Service 3 is healthy"} | ||
json.NewEncoder(w).Encode(response) | ||
} | ||
|
||
func health4Handler(w http.ResponseWriter, r *http.Request) { | ||
response := HealthResponse{Status: "ok", Message: "Service 4 is healthy"} | ||
json.NewEncoder(w).Encode(response) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Health Check API | ||
version: 1.0.0 | ||
paths: | ||
/api/v1/health1: | ||
get: | ||
summary: Health check for service 1 | ||
responses: | ||
'200': | ||
description: A successful response | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
status: | ||
type: string | ||
example: "ok" | ||
message: | ||
type: string | ||
example: "Service 1 is healthy" | ||
/api/v1/health2: | ||
get: | ||
summary: Health check for service 2 | ||
responses: | ||
'200': | ||
description: A successful response | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
status: | ||
type: string | ||
example: "ok" | ||
message: | ||
type: string | ||
example: "Service 2 is healthy" | ||
/api/v1/health3: | ||
get: | ||
summary: Health check for service 3 | ||
responses: | ||
'200': | ||
description: A successful response | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
status: | ||
type: string | ||
example: "ok" | ||
message: | ||
type: string | ||
example: "Service 3 is healthy" | ||
/api/v1/health4: | ||
get: | ||
summary: Health check for service 4 | ||
responses: | ||
'200': | ||
description: A successful response | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
status: | ||
type: string | ||
example: "ok" | ||
message: | ||
type: string | ||
example: "Service 4 is healthy" |