-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (35 loc) · 974 Bytes
/
main.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
36
37
38
39
40
41
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"time"
"github.com/blind3dd/gocasst/auth"
"github.com/blind3dd/gocasst/cass"
)
// Heartbeat says hb ok if endpoint works
func Heartbeat(w http.ResponseWriter, r *http.Request) {
if auth.AuthCheck(w, r) {
json.NewEncoder(w).Encode(ResponseStatus{Status: "OK", Code: 200})
fmt.Println(cass.LogTime() + ", Heartbeat Received with Status 200")
return
}
json.NewEncoder(w).Encode(ResponseStatus{Status: "Unauthorized", Code: 401})
fmt.Println(cass.LogTime() + ", Heartbeat request - Unauthorized")
}
func main() {
//var handler http.HandlerFunc
CassSession := cass.Session
defer CassSession.Close()
// router endpoints and handlers (endpoints.go)
router := NewRouter()
serv := &http.Server{
Addr: "127.0.0.1:8088",
Handler: router,
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
MaxHeaderBytes: 1 << 50,
}
log.Fatal(serv.ListenAndServe())
}