PracowniaProgramowania/backend/go_orm/main.go
2018-11-15 01:52:44 +01:00

34 lines
704 B
Go

package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World")
}
func hangleRequests() {
myRouter := mux.NewRouter().StrictSlash(true)
myRouter.HandleFunc("/", helloWorld).Methods("GET")
myRouter.HandleFunc("/users", AllUsers).Methods("GET")
myRouter.HandleFunc("/user/{name}/{email}", NewUser).Methods("POST")
myRouter.HandleFunc("/user/{name}", DeleteUser).Methods("DELETE")
myRouter.HandleFunc("/user/{name}/{email}", UpdateUser).Methods("PUT")
log.Fatal(http.ListenAndServe(":8081", myRouter))
}
func main() {
fmt.Println("GO ORM Tutorial")
InitialMigration()
hangleRequests()
}