From abce8035f3fbafa5b53ce5d2f6fb089aac3b495c Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 17 Feb 2023 20:20:36 +0100 Subject: [PATCH] refactor: remove main.go Signed-off-by: martin --- README.md | 2 +- src/init.go | 22 ++++++++++++++++++++++ src/main.go | 31 ------------------------------- 3 files changed, 23 insertions(+), 32 deletions(-) delete mode 100644 src/main.go diff --git a/README.md b/README.md index e1d958f..9eea173 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # immich-exporter -[![manual push](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml/badge.svg)](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml) +[![Publish Release](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml/badge.svg)](https://github.com/martabal/immich-exporter/actions/workflows/push_docker.yml)

  diff --git a/src/init.go b/src/init.go index 876f682..c8a4e72 100644 --- a/src/init.go +++ b/src/init.go @@ -6,13 +6,35 @@ import ( "immich-exporter/src/immich" "immich-exporter/src/models" "io/ioutil" + "net/http" "log" "os" "github.com/joho/godotenv" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" ) +func main() { + startup() + log.Println("Immich URL :", models.GetURL()) + log.Println("username :", models.GetUsername()) + log.Println("password :", models.Getpasswordmasked()) + log.Println("Started") + + http.HandleFunc("/metrics", metrics) + http.ListenAndServe(":8090", nil) +} + +func metrics(w http.ResponseWriter, r *http.Request) { + registry := prometheus.NewRegistry() + immich.Allrequests(registry) + h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{}) + h.ServeHTTP(w, r) + +} + func startup() { projectinfo() var envfile bool diff --git a/src/main.go b/src/main.go deleted file mode 100644 index c4b1e94..0000000 --- a/src/main.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "immich-exporter/src/immich" - "immich-exporter/src/models" - - "log" - "net/http" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" -) - -func main() { - startup() - log.Println("Immich URL :", models.GetURL()) - log.Println("username :", models.GetUsername()) - log.Println("password :", models.Getpasswordmasked()) - log.Println("Started") - - http.HandleFunc("/metrics", metrics) - http.ListenAndServe(":8090", nil) -} - -func metrics(w http.ResponseWriter, r *http.Request) { - registry := prometheus.NewRegistry() - immich.Allrequests(registry) - h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{}) - h.ServeHTTP(w, r) - -}