This repository was archived by the owner on Oct 14, 2024. It is now read-only.
File tree 3 files changed +14
-8
lines changed
3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ import (
10
10
11
11
func (mws * Controller ) getHealthHandler () webserver.HandlerFunc {
12
12
return func (req * request.RequestContext ) error {
13
- // Get current state from callback
14
- state := mws .healthCallback ()
13
+ // Get current health status from callback
14
+ status := mws .healthCallback ()
15
15
16
- // Encode and send output
17
- req .WriteJSON (state )
16
+ // Send output
17
+ if len (status ) > 0 {
18
+ req .WriteString (status )
19
+ }
18
20
req .Success ()
19
21
20
22
// Done
Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ type Options struct {
60
60
Middlewares []webserver.MiddlewareFunc
61
61
}
62
62
63
- // HealthCallback indicates a function that returns an object that will be returned as a JSON output.
64
- type HealthCallback func () interface {}
63
+ // HealthCallback indicates a function that returns a string that will be returned as the output.
64
+ type HealthCallback func () string
65
65
66
66
// -----------------------------------------------------------------------------
67
67
Original file line number Diff line number Diff line change 1
1
package metrics_test
2
2
3
3
import (
4
+ "encoding/json"
4
5
"fmt"
5
6
"math/rand"
6
7
"os"
@@ -129,10 +130,13 @@ func TestWebServer(t *testing.T) {
129
130
130
131
// -----------------------------------------------------------------------------
131
132
132
- func healthCallback () interface {} {
133
- return State {
133
+ func healthCallback () string {
134
+ state := State {
134
135
System : "all services running" ,
135
136
}
137
+
138
+ j , _ := json .Marshal (state )
139
+ return string (j )
136
140
}
137
141
138
142
func openBrowser (url string ) {
You can’t perform that action at this time.
0 commit comments