38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Receive and send informations about servers
|
|
package main
|
|
|
|
import (
|
|
h "infra-dashboard/Http"
|
|
tools "infra-dashboard/Tools"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/alexflint/go-arg"
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
var (
|
|
args struct {
|
|
Log string `arg:"-l,--logfile" help:"location of output logfile." default:"infra-dashboard-access.log"`
|
|
EnvFile string `arg:"-e,--envfile" help:"location of file containing environment variables." default:".env"`
|
|
Metrics bool `arg:"--metrics" help:"enable prometheus exporter on /metrics." default:"false"`
|
|
}
|
|
)
|
|
|
|
func main() {
|
|
arg.MustParse(&args)
|
|
tools.InitLog(args.Log)
|
|
tools.ReadDotEnvFile(args.EnvFile)
|
|
|
|
router := mux.NewRouter()
|
|
|
|
router.HandleFunc("/", h.RequestHandler).Methods("GET")
|
|
router.HandleFunc("/healthcheck", h.HealthHandler)
|
|
router.HandleFunc("/OS", h.GetOS).Methods("GET")
|
|
router.HandleFunc("/OS/{id}", h.GetOSbyID).Methods("GET")
|
|
router.HandleFunc("/distribution", h.GetDistributionList).Methods("GET")
|
|
router.HandleFunc("/distribution/{distribution}/version", h.GetVersionByDistributionList).Methods("GET")
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", router))
|
|
}
|