From 1ea17d598b2b3ac30c6d4b2817f4b9e96151d1aa Mon Sep 17 00:00:00 2001 From: loerac Date: Tue, 25 Aug 2020 11:38:41 -0500 Subject: [PATCH 1/3] Added post request to feed cat now --- catfeeder-machine/rest-api.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/catfeeder-machine/rest-api.go b/catfeeder-machine/rest-api.go index 1ef96ae..ace221b 100644 --- a/catfeeder-machine/rest-api.go +++ b/catfeeder-machine/rest-api.go @@ -36,6 +36,13 @@ func CreateNewFeedTime(w http.ResponseWriter, r *http.Request) { PrintFeedingTimes(ft) } +/*** + * @brief: Handle to feed the cat. + ***/ +func CreateFeednow(w http.ResponseWriter, r *http.Request) { + fmt.Println("Place holder to feed cat now, will update once TID003 is complete") +} + /** * @brief: Handle for recieving a specific feeding time. **/ @@ -74,6 +81,7 @@ func HomePage(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Cat Feeding times") fmt.Fprintln(w, "-----------------------") fmt.Fprintln(w, "Create new feeding times with '/feedingTime'") + fmt.Fprintln(w, "Create request to feed cat now with '/feedNow'") fmt.Fprintln(w, "Return all feeding time with '/feedingTimes'") fmt.Fprintln(w, "Return single feeding time with '/feedingTime/'") } @@ -85,6 +93,7 @@ func HandleRequests() { myRouter := mux.NewRouter().StrictSlash(true) myRouter.HandleFunc("/", HomePage) myRouter.HandleFunc("/feedingTime", CreateNewFeedTime).Methods("POST") + myRouter.HandleFunc("/feedNow", CreateFeednow).Methods("POST") myRouter.HandleFunc("/feedingTimes", ReturnAllFeedingTimes).Methods("GET") myRouter.HandleFunc("/feedingTime/{id}", ReturnSingleFeedingTime).Methods("GET") log.Fatal(http.ListenAndServe(":6969", myRouter)) From 3f95211f60c48f39a50b8002d3ad5a09e2e99b61 Mon Sep 17 00:00:00 2001 From: loerac Date: Tue, 25 Aug 2020 12:03:10 -0500 Subject: [PATCH 2/3] Updated function name to match API call --- catfeeder-machine/rest-api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catfeeder-machine/rest-api.go b/catfeeder-machine/rest-api.go index ace221b..d247d26 100644 --- a/catfeeder-machine/rest-api.go +++ b/catfeeder-machine/rest-api.go @@ -39,7 +39,7 @@ func CreateNewFeedTime(w http.ResponseWriter, r *http.Request) { /*** * @brief: Handle to feed the cat. ***/ -func CreateFeednow(w http.ResponseWriter, r *http.Request) { +func CreateFeedNow(w http.ResponseWriter, r *http.Request) { fmt.Println("Place holder to feed cat now, will update once TID003 is complete") } @@ -93,7 +93,7 @@ func HandleRequests() { myRouter := mux.NewRouter().StrictSlash(true) myRouter.HandleFunc("/", HomePage) myRouter.HandleFunc("/feedingTime", CreateNewFeedTime).Methods("POST") - myRouter.HandleFunc("/feedNow", CreateFeednow).Methods("POST") + myRouter.HandleFunc("/feedNow", CreateFeedNow).Methods("POST") myRouter.HandleFunc("/feedingTimes", ReturnAllFeedingTimes).Methods("GET") myRouter.HandleFunc("/feedingTime/{id}", ReturnSingleFeedingTime).Methods("GET") log.Fatal(http.ListenAndServe(":6969", myRouter)) From 357fa070ca04005f2525368d9a293badab87e09d Mon Sep 17 00:00:00 2001 From: loerac Date: Tue, 25 Aug 2020 12:04:14 -0500 Subject: [PATCH 3/3] Updated description to say 'return' instead of 'recieve' --- catfeeder-machine/rest-api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catfeeder-machine/rest-api.go b/catfeeder-machine/rest-api.go index d247d26..e93bceb 100644 --- a/catfeeder-machine/rest-api.go +++ b/catfeeder-machine/rest-api.go @@ -44,7 +44,7 @@ func CreateFeedNow(w http.ResponseWriter, r *http.Request) { } /** - * @brief: Handle for recieving a specific feeding time. + * @brief: Handle for returning a specific feeding time. **/ func ReturnSingleFeedingTime(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) @@ -64,7 +64,7 @@ func ReturnSingleFeedingTime(w http.ResponseWriter, r *http.Request) { } /** - * @brief: Handle for recieving all the feeding times. + * @brief: Handle for returning all the feeding times. **/ func ReturnAllFeedingTimes(w http.ResponseWriter, r *http.Request) { mut.Lock() @@ -75,7 +75,7 @@ func ReturnAllFeedingTimes(w http.ResponseWriter, r *http.Request) { } /** - * @brief: Handle to recieving info on REST API. + * @brief: Handle to returning info on REST API. **/ func HomePage(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Cat Feeding times")