workshop/cmd/workshop.go
Dmitry Sirotkin 083c02116b init
2025-03-21 19:49:54 +03:00

28 lines
546 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("/user/new", controllers.CreateService).Methods("POST")
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)
}
}