You've already forked gun-manager-backend
initial commit
This commit is contained in:
46
main.go
Normal file
46
main.go
Normal 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())
|
||||
}
|
||||
Reference in New Issue
Block a user