Fixed flags parsing. Added more handlers.
This commit is contained in:
parent
5f9485fe3c
commit
d4e7a7fa25
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"dwelling-upload/internal/configuration"
|
"dwelling-upload/internal/configuration"
|
||||||
|
"dwelling-upload/internal/handlers"
|
||||||
"dwelling-upload/pkg/server"
|
"dwelling-upload/pkg/server"
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
@ -10,16 +11,26 @@ import (
|
|||||||
"syscall"
|
"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() {
|
func main() {
|
||||||
config, err := configuration.LoadConfiguration(configPath)
|
flag.Parse()
|
||||||
|
|
||||||
|
config, err := configuration.LoadConfiguration(*configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hand := handlers.NewUploadHandlers(config)
|
||||||
|
|
||||||
srv := server.NewHttpServer()
|
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 {
|
if err := srv.Start(config.SplitNetworkAddress()); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user