
Some checks failed
Deploy to Server (Docker) / deploy (push) Failing after 1m0s
2 +- 3 4 5
36 lines
881 B
Go
36 lines
881 B
Go
package main
|
|
|
|
import (
|
|
"gocommunity.ru/workshop/internal/controllers"
|
|
"fmt"
|
|
"github.com/gorilla/mux"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
|
|
router := mux.NewRouter()
|
|
|
|
router.HandleFunc("/service/new", controllers.CreateService).Methods("POST")
|
|
router.HandleFunc("/service/accept", controllers.AcceptVehicle).Methods("POST")
|
|
router.HandleFunc("/service/all", controllers.GetServices).Methods("GET")
|
|
|
|
//Vehicle
|
|
router.HandleFunc("/vehicle/new", controllers.CreateVehicle).Methods("POST")
|
|
router.HandleFunc("/vehicle/all", controllers.GetvehiclesInService).Methods("GET")
|
|
|
|
|
|
router.HandleFunc("/contacts/new", controllers.CreateContact).Methods("POST")
|
|
router.HandleFunc("/me/contacts", controllers.GetContacts).Methods("GET")
|
|
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8000"
|
|
}
|
|
|
|
err := http.ListenAndServe(":"+port, router)
|
|
if err != nil {
|
|
fmt.Print(err)
|
|
}
|
|
} |