Mastering Go Web Services by Kozyra Nathan

Mastering Go Web Services by Kozyra Nathan

Author:Kozyra, Nathan
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2015-04-13T16:00:00+00:00


Our statuses will consist of the user's information, a timestamp, and the text of the status message. Nothing too fancy for now!

Next, we'll need to add API endpoints for creating, reading, updating, and deleting the statuses. So, in our api.go file, let's add these:

func Init() { Routes = mux.NewRouter() Routes.HandleFunc("/interface", APIInterface).Methods("GET", "POST", "PUT", "UPDATE") Routes.HandleFunc("/api/users", UserCreate).Methods("POST") Routes.HandleFunc("/api/users", UsersRetrieve).Methods("GET") Routes.HandleFunc("/api/users/{id:[0-9]+}", UsersUpdate).Methods("PUT") Routes.HandleFunc("/api/users", UsersInfo).Methods("OPTIONS") Routes.HandleFunc("/api/statuses",StatusCreate).Methods("POST") Routes.HandleFunc("/api/statuses",StatusRetrieve).Methods("GET") Routes.HandleFunc("/api/statuses/{id:[0-9]+}",StatusUpdate).Methods("PUT") Routes.HandleFunc("/api/statuses/{id:[0-9]+}",StatusDelete).Methods("DELETE") Routes.HandleFunc("/authorize", ApplicationAuthorize).Methods("POST") Routes.HandleFunc("/authorize", ApplicationAuthenticate).Methods("GET") Routes.HandleFunc("/authorize/{service:[a-z]+}", ServiceAuthorize).Methods("GET") Routes.HandleFunc("/connect/{service:[a-z]+}", ServiceConnect).Methods("GET") Routes.HandleFunc("/oauth/token", CheckCredentials).Methods("POST") }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.