-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add custom handler for health (#40)
Co-authored-by: David MICHENEAU <david.micheneau@orange.com>
- Loading branch information
1 parent
516dda5
commit e0332f5
Showing
3 changed files
with
82 additions
and
41 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
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 |
---|---|---|
@@ -1,29 +1,27 @@ | ||
package health | ||
|
||
import ( | ||
"net" | ||
"net/http" | ||
"time" | ||
) | ||
// import ( | ||
// "time" | ||
// ) | ||
|
||
const ( | ||
timeoutR = 1 * time.Second | ||
) | ||
// const ( | ||
// timeoutR = 1 * time.Second | ||
// ) | ||
|
||
// healthHandler returns a http.Handler that returns a health check response | ||
func Handler() http.Handler { | ||
// TODO - Implement a new way to ask the health of the application (e.g. check image updater) | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
_, err := net.DialTimeout("tcp", ":9081", timeoutR) | ||
if err != nil { | ||
return | ||
} | ||
// func DefaultHandler() http.Handler { | ||
// // TODO - Implement a new way to ask the health of the application (e.g. check image updater) | ||
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
// _, err := net.DialTimeout("tcp", ":9081", timeoutR) | ||
// if err != nil { | ||
// return | ||
// } | ||
|
||
// TODO - Implement an http.Handler content-type | ||
w.Header().Set("Content-Type", "application/json") | ||
_, err = w.Write([]byte(`{"status":"ok"}`)) | ||
if err != nil { | ||
return | ||
} | ||
}) | ||
} | ||
// // TODO - Implement an http.Handler content-type | ||
// w.Header().Set("Content-Type", "application/json") | ||
// _, err = w.Write([]byte(`{"status":"ok"}`)) | ||
// if err != nil { | ||
// return | ||
// } | ||
// }) | ||
// } |
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