You've already forked gun-manager-backend
commit
This commit is contained in:
30
main.go
30
main.go
@@ -3,13 +3,11 @@ 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"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -29,18 +27,18 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/", Guns.Get).Methods("GET")
|
||||
r.HandleFunc("/photo/{id}/{fileName}", Photo.Get).Methods("GET")
|
||||
e := echo.New()
|
||||
e.Use(middleware.Logger())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||
AllowOrigins: []string{"localhost"},
|
||||
AllowMethods: nil,
|
||||
}))
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: r,
|
||||
Addr: "0.0.0.0:8000",
|
||||
WriteTimeout: 15 * time.Second,
|
||||
ReadTimeout: 15 * time.Second,
|
||||
}
|
||||
e.GET("/gun", Guns.Get)
|
||||
e.GET("/gun/:id", Guns.GetById)
|
||||
e.POST("/gun", Guns.Post)
|
||||
e.GET("/gun/photo/:id/:filename", Guns.GetPhoto)
|
||||
|
||||
log.Println("Starting Server: 0.0.0.0:8000")
|
||||
|
||||
log.Fatal(srv.ListenAndServe())
|
||||
e.Logger.Fatal(e.Start(":8000"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user