Created
March 9, 2018 09:08
-
-
Save swanandvk/6ae67df4be000accaf12b0915c3dc32c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main(){ | |
| fmt.Println("magic is happening on port 8081") | |
| //creating local array | |
| users=append(users,User{ID:"1",Firstname:"Swanand",Lastname:"Keskar"}) | |
| users=append(users,User{ID:"2",Firstname:"Akshay",Lastname:"Joshi"}) | |
| router:=mux.NewRouter() | |
| router.HandleFunc("/users",GetUsers).Methods("GET") | |
| router.HandleFunc("/users/{id}",GetUserById).Methods("GET") | |
| router.HandleFunc("/users/{id}",CreateUser).Methods("POST") | |
| router.HandleFunc("/users/{id}",DeleteUser).Methods("DELETE") | |
| log.Fatal(http.ListenAndServe(":8081",router)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment