From 3f7196f745da44102ff7554847e02a9cd3184fa0 Mon Sep 17 00:00:00 2001 From: Joe Corall Date: Tue, 3 Sep 2024 15:13:36 -0400 Subject: [PATCH] Put --server flag back --- main.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 2f28706..8d6a7bb 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "flag" "fmt" "log/slog" + "net/http" "os" "reflect" "regexp" @@ -13,6 +14,7 @@ import ( "strings" "github.com/lehigh-university-libraries/fabricator/internal/contributor" + "github.com/lehigh-university-libraries/fabricator/internal/handlers" "github.com/lehigh-university-libraries/fabricator/internal/tgn" "github.com/lehigh-university-libraries/go-islandora/workbench" ) @@ -232,12 +234,25 @@ func readCSVWithJSONTags(filePath string) (map[string]bool, []map[string][]strin } func main() { + var serverMode bool - // Define the source and target flags + flag.BoolVar(&serverMode, "server", false, "Set to true to run as server") source := flag.String("source", "", "Path to the source CSV file") target := flag.String("target", "", "Path to the target CSV file") flag.Parse() + if serverMode { + // Start HTTP server + http.HandleFunc("/workbench/check", handlers.CheckMyWork) + + slog.Info("Starting server on :8080") + if err := http.ListenAndServe(":8080", nil); err != nil { + panic(err) + } + } + + // Define the source and target flags + if *source == "" || *target == "" { fmt.Println("Source and target flags are required") flag.Usage()