package main import ( "flag" "git.siteworxpro.com/gun-manager/Handlers/Guns" "git.siteworxpro.com/gun-manager/sql" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "log" "os" ) func main() { var dbfile string flag.StringVar(&dbfile, "database", "", "the database file to load") flag.Parse() if dbfile == "" { flag.Usage() os.Exit(1) } _, err := sql.NewDb(dbfile) if err != nil { log.Fatal(err) } e := echo.New() e.Use(middleware.Logger()) e.Use(middleware.Recover()) e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: []string{"localhost"}, AllowMethods: nil, })) e.GET("/gun", Guns.Get) e.GET("/gun/:id", Guns.GetById) e.DELETE("/gun/:id", Guns.DeleteById) e.POST("/gun", Guns.Post) e.GET("/gun/photo/:id/:filename", Guns.GetPhoto) e.POST("/gun/photo/:id", Guns.PostPhoto) e.DELETE("/gun/photo/:id", Guns.DeletePhoto) e.GET("/gun/photo/:id/:size/:filename", Guns.GetPhotoResize) e.Logger.Fatal(e.Start(":8000")) }