-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathServiceStateDispatcher.go
More file actions
36 lines (31 loc) · 901 Bytes
/
ServiceStateDispatcher.go
File metadata and controls
36 lines (31 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import "net/http"
import "encoding/json"
import "errors"
import "log"
type ServiceStateRequest struct {
BasicRequest
}
type ServiceStateResponse struct {
UpTime bool
WorkFromRoot bool
ProcStat bool
MemInfo bool
}
type ServiceStateDispatcher struct {
}
func (serviceStateDispatcher *ServiceStateDispatcher) Dispatch(request Request, responseWriter http.ResponseWriter, httpRequest *http.Request) error {
//this is service is not need lock
serviceState := ServiceStateResponse{true, true, true, true}
js, err := json.Marshal(serviceState)
if err != nil {
http.Error(responseWriter, err.Error(), http.StatusInternalServerError)
stErr := "error: Can't service state response"
log.Println(stErr)
responseWriter.Write(js)
return errors.New(stErr)
}
responseWriter.Header().Set("Content-Type", "application/json")
responseWriter.Write(js)
return nil
}