forked from fawick/go-mapnik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http_handlers.go
35 lines (32 loc) · 1.11 KB
/
http_handlers.go
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
package maptiles
import (
"fmt"
"net/http"
"runtime"
"time"
)
// PingHandler provides an api route for server health check
func PingHandler(w http.ResponseWriter, r *http.Request) {
start := time.Now()
response := make(map[string]interface{})
response["status"] = "ok"
result := make(map[string]interface{})
result["result"] = "Pong"
response["data"] = result
status := SendJsonResponseFromInterface(w, r, response)
Ligneous.Info(fmt.Sprintf("%v %v %v [%v]", r.RemoteAddr, r.URL.Path, time.Since(start), status))
}
// ServerProfileHandler returns basic server stats.
func ServerProfileHandler(startTime time.Time, w http.ResponseWriter, r *http.Request) {
start := time.Now()
var data map[string]interface{}
data = make(map[string]interface{})
data["registered"] = startTime.UTC()
data["uptime"] = time.Since(startTime).Seconds()
data["num_cores"] = runtime.NumCPU()
response := make(map[string]interface{})
response["status"] = "ok"
response["data"] = data
status := SendJsonResponseFromInterface(w, r, response)
Ligneous.Info(fmt.Sprintf("%v %v %v [%v]", r.RemoteAddr, r.URL.Path, time.Since(start), status))
}