From d4e7a7fa2523b062720c8e126f561639d5f669d6 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 6 Feb 2022 15:25:27 +0400 Subject: [PATCH] Fixed flags parsing. Added more handlers. --- cmd/dwelling-upload/main.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/dwelling-upload/main.go b/cmd/dwelling-upload/main.go index fea2de5..be4cd06 100644 --- a/cmd/dwelling-upload/main.go +++ b/cmd/dwelling-upload/main.go @@ -2,6 +2,7 @@ package main import ( "dwelling-upload/internal/configuration" + "dwelling-upload/internal/handlers" "dwelling-upload/pkg/server" "flag" "log" @@ -10,16 +11,26 @@ import ( "syscall" ) -var configPath string = *flag.String("conf", "config.yaml", "path to configuration file") +var configPath *string = flag.String("conf", "config.yaml", "path to configuration file") func main() { - config, err := configuration.LoadConfiguration(configPath) + flag.Parse() + + config, err := configuration.LoadConfiguration(*configPath) if err != nil { log.Fatalln(err) } + hand := handlers.NewUploadHandlers(config) + srv := server.NewHttpServer() + srv.ServeStatic("/assets/*filepath", handlers.StaticAssets()) + + srv.GET("/", hand.Index) + srv.POST("/", hand.Upload) + srv.GET("/:hash/:name", hand.Upload) + if err := srv.Start(config.SplitNetworkAddress()); err != nil { log.Fatalln(err) }