-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (32 loc) · 1.06 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
package main
import (
"fmt"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/testokur/testokur-light/api/cities"
"github.com/testokur/testokur-light/api/licensetypes"
"github.com/testokur/testokur-light/api/localization"
"github.com/testokur/testokur-light/config"
"github.com/urfave/negroni"
)
func healthCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprintf(w, "Healthy!")
}
func prometheusMetrics(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
promhttp.Handler().ServeHTTP(w, r)
}
func main() {
router := httprouter.New()
router.GET("/hc", healthCheck)
router.GET("/api/v1/cities", cities.Get)
router.GET("/api/v1/license-types", licensetypes.Get)
router.GET("/api/v1/localization", localization.Get)
router.GET("/metrics", prometheusMetrics)
n := negroni.New()
n.Use(negroni.NewLogger())
n.UseHandler(router)
log.Println(fmt.Sprintf("Listening on %s...", config.GetPort()))
log.Fatal(http.ListenAndServe(config.GetPort(), n))
}