blob: 54a4d03d3a2186933ca3e9359cdbab629a7cc05b [file] [log] [blame]
package main
import (
"flag"
"net/http"
"github.com/gorilla/mux"
"go.skia.org/infra/go/common"
"go.skia.org/infra/go/httputils"
"go.skia.org/infra/go/sklog"
)
// flags
var (
local = flag.Bool("local", false, "Running locally if true. As opposed to in production.")
port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')")
promPort = flag.String("prom_port", ":20000", "Metrics service address (e.g., ':10110')")
resourcesDir = flag.String("resources_dir", "", "The directory to find templates, JS, and CSS files. If blank the current directory will be used.")
)
func main() {
common.InitWithMust(
"api",
common.PrometheusOpt(promPort),
common.MetricsLoggingOpt(),
)
r := mux.NewRouter()
r.PathPrefix("/").Handler(http.HandlerFunc(httputils.MakeResourceHandler(*resourcesDir)))
h := httputils.LoggingGzipRequestResponse(r)
if !*local {
h = httputils.HealthzAndHTTPS(h)
}
http.Handle("/", h)
sklog.Info("Ready to serve.")
sklog.Fatal(http.ListenAndServe(*port, nil))
}