shadow errors

This commit is contained in:
Cadey Ratio 2019-03-27 07:40:42 -07:00
parent 7e6a1cbd58
commit bce017f56f
2 changed files with 11 additions and 8 deletions

View File

@ -30,11 +30,15 @@ func main() {
port = "29384" port = "29384"
} }
ctx := ln.WithF(opname.With(context.Background(), "main"), ln.F{
"port": port,
})
prometheus.Register(prommod.NewCollector("christine")) prometheus.Register(prommod.NewCollector("christine"))
s, err := Build() s, err := Build()
if err != nil { if err != nil {
ln.FatalErr(context.Background(), err, ln.Action("Build")) ln.FatalErr(ctx, err, ln.Action("Build"))
} }
mux := http.NewServeMux() mux := http.NewServeMux()
@ -43,8 +47,8 @@ func main() {
}) })
mux.Handle("/", s) mux.Handle("/", s)
ln.Log(context.Background(), ln.F{"action": "http_listening", "port": port}) ln.Log(ctx, ln.Action("http_listening"))
http.ListenAndServe(":"+port, mux) ln.FatalErr(ctx, http.ListenAndServe(":"+port, mux))
} }
// Site is the parent object for https://christine.website's backend. // Site is the parent object for https://christine.website's backend.
@ -56,7 +60,6 @@ type Site struct {
jsonFeed *jsonfeed.Feed jsonFeed *jsonfeed.Feed
mux *http.ServeMux mux *http.ServeMux
sitemap []byte
xffmw *xff.XFF xffmw *xff.XFF
} }
@ -189,7 +192,7 @@ func Build() (*Site, error) {
}) })
s.mux.Handle("/sitemap.xml", middleware.Metrics("sitemap", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { s.mux.Handle("/sitemap.xml", middleware.Metrics("sitemap", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/xml") w.Header().Set("Content-Type", "application/xml")
smi.WriteTo(w) _, _ = smi.WriteTo(w)
}))) })))
return s, nil return s, nil

View File

@ -26,9 +26,9 @@ var (
) )
func init() { func init() {
prometheus.Register(requestCounter) _ = prometheus.Register(requestCounter)
prometheus.Register(requestDuration) _ = prometheus.Register(requestDuration)
prometheus.Register(requestInFlight) _ = prometheus.Register(requestInFlight)
} }
// Metrics captures request duration, request count and in-flight request count // Metrics captures request duration, request count and in-flight request count