From 75d9ca6d230c12c60328c2d088f2c32f69072f98 Mon Sep 17 00:00:00 2001 From: "ivan.rigo" <ivan.rigo@etu.hesge.ch> Date: Wed, 7 Dec 2022 13:37:30 +0100 Subject: [PATCH] Final Push --- web-service-gin/Gnutella.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web-service-gin/Gnutella.go b/web-service-gin/Gnutella.go index 6fcc032..635d1e3 100644 --- a/web-service-gin/Gnutella.go +++ b/web-service-gin/Gnutella.go @@ -1,5 +1,9 @@ package main +/*Programme ayant pour but d'implémenter Gnutella en GO et utilisant REST pour communiquer +Réalisé par : Ivan Rigo et John Jenni +*/ + import ( "fmt" "io/ioutil" @@ -33,17 +37,20 @@ var err error var assignTransM sync.Mutex var endResult string +// Required Full route to communicate func getRequest(urlTxt string) { resp, err := http.Get(urlTxt) printErr(err) fmt.Println(resp.Status) } +// Print the result of the search func showReq(c *gin.Context) { fmt.Println(endResult) c.IndentedJSON(http.StatusOK, endResult) } +// Start the search func initReq(c *gin.Context) { msgId = rand.Intn(100) + data.ID transmitter = -1 @@ -65,6 +72,7 @@ func receiveReq(c *gin.Context) { msgIdInt, err := strconv.Atoi(c.Param("msgId")) printErr(err) + // msgID aloow to recognize first call of new search assignTransM.Lock() if msgId != msgIdInt { msgId = msgIdInt @@ -100,7 +108,7 @@ func receiveReq(c *gin.Context) { c.Status(http.StatusOK) } -//Called by child when ressource is find +//Called by child when ressource is found func foundReq(c *gin.Context) { if transmitter == -1 { if endResult == "" { -- GitLab