mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-24 08:53:48 +01:00
chore(deps): bump github.com/TwiN/health from 1.5.0 to 1.6.0 (#394)
Bumps [github.com/TwiN/health](https://github.com/TwiN/health) from 1.5.0 to 1.6.0. - [Release notes](https://github.com/TwiN/health/releases) - [Commits](https://github.com/TwiN/health/compare/v1.5.0...v1.6.0) --- updated-dependencies: - dependency-name: github.com/TwiN/health dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
616a654b27
commit
37bea336ca
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.19
|
||||
require (
|
||||
github.com/TwiN/g8 v1.4.0
|
||||
github.com/TwiN/gocache/v2 v2.2.0
|
||||
github.com/TwiN/health v1.5.0
|
||||
github.com/TwiN/health v1.6.0
|
||||
github.com/TwiN/whois v1.1.0
|
||||
github.com/coreos/go-oidc/v3 v3.4.0
|
||||
github.com/go-ping/ping v0.0.0-20210911151512-381826476871
|
||||
|
4
go.sum
4
go.sum
@ -61,8 +61,8 @@ github.com/TwiN/g8 v1.4.0 h1:RUk5xTtxKCdMo0GGSbBVyjtAAfi2nqVbA9E0C4u5Cxo=
|
||||
github.com/TwiN/g8 v1.4.0/go.mod h1:ECyGJsoIb99klUfvVQoS1StgRLte9yvvPigGrHdy284=
|
||||
github.com/TwiN/gocache/v2 v2.2.0 h1:M3B36KyH24BntxLrLaUb2kgTdq8DzCnfod0IekLG57w=
|
||||
github.com/TwiN/gocache/v2 v2.2.0/go.mod h1:SnUuBsrwGQeNcDG6vhkOMJnqErZM0JGjgIkuKryokYA=
|
||||
github.com/TwiN/health v1.5.0 h1:ETTtbQfUbiiIiVTSpAiNzesHQvm8qarV/8ctlZsVhwA=
|
||||
github.com/TwiN/health v1.5.0/go.mod h1:Z6TszwQPMvtSiVx1QMidVRgvVr4KZGfiwqcD7/Z+3iw=
|
||||
github.com/TwiN/health v1.6.0 h1:L2ks575JhRgQqWWOfKjw9B0ec172hx7GdToqkYUycQM=
|
||||
github.com/TwiN/health v1.6.0/go.mod h1:Z6TszwQPMvtSiVx1QMidVRgvVr4KZGfiwqcD7/Z+3iw=
|
||||
github.com/TwiN/whois v1.1.0 h1:lhyrC/9yIXntEnbJ+0IBy9Z5NBcreieYyamlvniwq88=
|
||||
github.com/TwiN/whois v1.1.0/go.mod h1:9WbCzYlR+r5eq9vbgJVh7A4H2uR2ct4wKEB0/QITJ/c=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
|
24
vendor/github.com/TwiN/health/health.go
generated
vendored
24
vendor/github.com/TwiN/health/health.go
generated
vendored
@ -39,10 +39,24 @@ func (h *healthHandler) WithJSON(v bool) *healthHandler {
|
||||
|
||||
// ServeHTTP serves the HTTP request for the health handler
|
||||
func (h *healthHandler) ServeHTTP(writer http.ResponseWriter, _ *http.Request) {
|
||||
var statusCode int
|
||||
var body []byte
|
||||
statusCode, body, useJSON := h.getResponseStatusCodeAndBodyAndWhetherBodyUsesJSON()
|
||||
if useJSON {
|
||||
writer.Header().Set("Content-Type", "application/json")
|
||||
}
|
||||
writer.WriteHeader(statusCode)
|
||||
_, _ = writer.Write(body)
|
||||
}
|
||||
|
||||
func (h *healthHandler) GetResponseStatusCodeAndBody() (statusCode int, body []byte) {
|
||||
statusCode, body, _ = h.getResponseStatusCodeAndBodyAndWhetherBodyUsesJSON()
|
||||
return statusCode, body
|
||||
}
|
||||
|
||||
func (h *healthHandler) getResponseStatusCodeAndBodyAndWhetherBodyUsesJSON() (statusCode int, body []byte, useJSON bool) {
|
||||
var status Status
|
||||
var reason string
|
||||
h.mutex.RLock()
|
||||
status, reason, useJSON := h.status, h.reason, h.useJSON
|
||||
status, reason, useJSON = h.status, h.reason, h.useJSON
|
||||
h.mutex.RUnlock()
|
||||
if status == Up {
|
||||
statusCode = http.StatusOK
|
||||
@ -52,7 +66,6 @@ func (h *healthHandler) ServeHTTP(writer http.ResponseWriter, _ *http.Request) {
|
||||
if useJSON {
|
||||
// We can safely ignore the error here because we know that both values are strings, therefore are supported encoders.
|
||||
body, _ = json.Marshal(responseBody{Status: string(status), Reason: reason})
|
||||
writer.Header().Set("Content-Type", "application/json")
|
||||
} else {
|
||||
if len(reason) == 0 {
|
||||
body = []byte(status)
|
||||
@ -60,8 +73,7 @@ func (h *healthHandler) ServeHTTP(writer http.ResponseWriter, _ *http.Request) {
|
||||
body = []byte(string(status) + ": " + reason)
|
||||
}
|
||||
}
|
||||
writer.WriteHeader(statusCode)
|
||||
_, _ = writer.Write(body)
|
||||
return
|
||||
}
|
||||
|
||||
// Handler retrieves the health handler
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -4,7 +4,7 @@ github.com/TwiN/g8
|
||||
# github.com/TwiN/gocache/v2 v2.2.0
|
||||
## explicit; go 1.19
|
||||
github.com/TwiN/gocache/v2
|
||||
# github.com/TwiN/health v1.5.0
|
||||
# github.com/TwiN/health v1.6.0
|
||||
## explicit; go 1.19
|
||||
github.com/TwiN/health
|
||||
# github.com/TwiN/whois v1.1.0
|
||||
|
Loading…
Reference in New Issue
Block a user