diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/web/main.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd/web/main.go b/cmd/web/main.go new file mode 100644 index 0000000..3f16dec --- /dev/null +++ b/cmd/web/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "log" + "net/http" + "os" + + "github.com/go-chi/chi" + + "git.ofmax.li/iserv/internal/db/redis" + "git.ofmax.li/iserv/internal/image" +) + +func main() { + connPool := redis.CreatePool("localhost:6379") + db := redis.NewRedisImageRepo(connPool) + + storagePath, err := os.Getwd() + if err != nil { + log.Fatal("couldn't find directory to write images to") + } + + imageService := image.NewService(db, storagePath) + imageHandler := image.NewHandler(imageService) + + r := chi.NewRouter() + + r.Get("/i", imageHandler.GetImage) + r.Post("/i", imageHandler.PostImage) + log.Print("starting imageserv") + log.Fatal(http.ListenAndServe(":8080", r)) +} |