initial commit

This commit is contained in:
2023-03-19 22:13:49 -04:00
commit 717c9e08d6
12 changed files with 367 additions and 0 deletions

46
main.go Normal file
View File

@@ -0,0 +1,46 @@
package main
import (
"flag"
"git.siteworxpro.com/gun-manager/Handlers/Guns"
"git.siteworxpro.com/gun-manager/Handlers/Photo"
"git.siteworxpro.com/gun-manager/sql"
"github.com/gorilla/mux"
"log"
"net/http"
"os"
"time"
)
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)
}
r := mux.NewRouter()
r.HandleFunc("/", Guns.Get).Methods("GET")
r.HandleFunc("/photo/{id}/{fileName}", Photo.Get).Methods("GET")
srv := &http.Server{
Handler: r,
Addr: "0.0.0.0:8000",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Println("Starting Server: 0.0.0.0:8000")
log.Fatal(srv.ListenAndServe())
}