From 6f342c8888686603a81800cbc800f65caf22b1ce Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Fri, 8 Sep 2023 12:45:46 -0400 Subject: [PATCH] Use anyhttp --- go.mod | 2 +- go.sum | 4 ++-- main.go | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d302191..885ef53 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module go.balki.me/collage-maker go 1.21 require ( - github.com/oliamb/cutter v0.2.2 + go.balki.me/anyhttp v0.2.0 go.oneofone.dev/resize v1.0.1 ) diff --git a/go.sum b/go.sum index b1f0e63..5febfba 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ -github.com/oliamb/cutter v0.2.2 h1:Lfwkya0HHNU1YLnGv2hTkzHfasrSMkgv4Dn+5rmlk3k= -github.com/oliamb/cutter v0.2.2/go.mod h1:4BenG2/4GuRBDbVm/OPahDVqbrOemzpPiG5mi1iryBU= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.balki.me/anyhttp v0.2.0 h1:W6aGcmjF5CMJvJYtbYCywxnYoErFhFc76vwaqUG5FAQ= +go.balki.me/anyhttp v0.2.0/go.mod h1:JhfekOIjgVODoVqUCficjpIgmB3wwlB7jhN0eN2EZ/s= go.oneofone.dev/resize v1.0.1 h1:HjpVar/4pxMGrjO44ThaMX1Q5UOBw0KxzbxxRDZPQuA= go.oneofone.dev/resize v1.0.1/go.mod h1:zGFmn7q4EUZVlnDmxqf+b0mWpxsTt0MH2yx6ng8tpq0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/main.go b/main.go index 1880d0b..db9a528 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( "log/slog" + "go.balki.me/anyhttp" "go.balki.me/collage-maker/collage" ) @@ -25,6 +26,7 @@ var ( localAssets bool collageNameGen *nameGen imagesDirFs fs.FS + listenAddr string // go:embed web/* webFS embed.FS @@ -34,6 +36,7 @@ func main() { flag.StringVar(&imagesDir, "images-dir", "images", "Sets the images dir") flag.StringVar(&collageDir, "collages-dir", "collages", "Sets the collages dir") flag.BoolVar(&localAssets, "local-assets", false, "Serve local assets for testing") + flag.StringVar(&listenAddr, "addr", "127.0.0.1:8767", "Sets the collages dir") flag.Parse() @@ -89,7 +92,7 @@ func main() { } w.Write([]byte(collageFile)) }) - if err := http.ListenAndServe(":8767", nil); err != nil { + if err := anyhttp.ListenAndServe(listenAddr, nil); err != nil { slog.Error("http ListenAndServe failed", "error", err) } }