1
0

Fixed flags parsing. Added more handlers.

This commit is contained in:
Alexander Andreev 2022-02-06 15:25:27 +04:00
parent 5f9485fe3c
commit d4e7a7fa25
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -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)
}