diff --git a/web-service-gin/Gnutella.go b/web-service-gin/Gnutella.go index 6fcc032f476bc84e8103fe92f6c0acf8a7c74fa8..635d1e3eec58f2552e6429a2c96cca0a20e3f59d 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 == "" {