-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
52 lines (43 loc) · 1.03 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"log"
"net/http"
"github.com/brigadecore/badgr/internal/badges"
"github.com/brigadecore/badgr/internal/badges/redis"
libHTTP "github.com/brigadecore/brigade-foundations/http"
"github.com/brigadecore/brigade-foundations/signals"
"github.com/brigadecore/brigade-foundations/version"
"github.com/gorilla/mux"
)
func main() {
log.Printf(
"Starting Badgr -- version %s -- commit %s",
version.Version(),
version.Commit(),
)
cacheConfig, err := redisCacheConfig()
if err != nil {
log.Fatal(err)
}
handler := badges.NewHandler(
badges.NewService(),
redis.NewCache(cacheConfig),
)
router := mux.NewRouter()
router.StrictSlash(true)
router.HandleFunc(
"/v1/github/checks/{owner}/{repo}/badge.svg",
handler.ServeHTTP,
).Methods(http.MethodGet)
router.HandleFunc("/healthz", libHTTP.Healthz).Methods(http.MethodGet)
serverConfig, err := serverConfig()
if err != nil {
log.Fatal(err)
}
log.Println(
libHTTP.NewServer(
router,
&serverConfig,
).ListenAndServe(signals.Context()),
)
}