Separate run command from main function

This commit is contained in:
2024-04-28 22:26:53 +07:00
parent 5ca6cdd129
commit e6344743d5
12 changed files with 74 additions and 79 deletions

19
main.go
View File

@ -1,24 +1,9 @@
package main
import (
"fmt"
"net/http"
"github.com/fossyy/filekeeper/middleware"
"github.com/fossyy/filekeeper/routes"
"github.com/fossyy/filekeeper/utils"
"github.com/fossyy/filekeeper/app"
)
func main() {
serverAddr := fmt.Sprintf("%s:%s", utils.Getenv("SERVER_HOST"), utils.Getenv("SERVER_PORT"))
server := http.Server{
Addr: serverAddr,
Handler: middleware.Handler(routes.SetupRoutes()),
}
fmt.Printf("Listening on http://%s\n", serverAddr)
err := server.ListenAndServe()
if err != nil {
return
}
app.Start()
}