28 lines
546 B
Go
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)
|
|
}
|
|
} |