MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / uptimeHandler

Function uptimeHandler

hello/hello.go:145–158  ·  view source on GitHub ↗
(startTime time.Time)

Source from the content-addressed store, hash-verified

143}
144
145func uptimeHandler(startTime time.Time) http.HandlerFunc {
146 return func(w http.ResponseWriter, r *http.Request) {
147 // Note that if autoupdate is enabled, the uptime is reset when a new client
148 // release is available
149 resp := &OriginUpTime{StartTime: startTime, UpTime: time.Now().Sub(startTime).String()}
150 respJson, err := json.Marshal(resp)
151 if err != nil {
152 w.WriteHeader(http.StatusInternalServerError)
153 } else {
154 w.Header().Set("Content-Type", "application/json")
155 _, _ = w.Write(respJson)
156 }
157 }
158}
159
160// This handler will echo message
161func websocketHandler(log *zerolog.Logger, upgrader websocket.Upgrader) http.HandlerFunc {

Callers 1

StartHelloWorldServerFunction · 0.85

Calls 6

StringMethod · 0.65
WriteMethod · 0.65
MarshalMethod · 0.45
WriteHeaderMethod · 0.45
SetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected