diff --git a/CTng/server/Gossiper_server.go b/CTng/server/Gossiper_server.go index e6e975a..be37814 100644 --- a/CTng/server/Gossiper_server.go +++ b/CTng/server/Gossiper_server.go @@ -29,7 +29,9 @@ import ( ) type Gossiper interface { - // Response to entering the 'base page' of a gossiper. + // Error response to "/". + basePage() + // Error response to "/gossiper/". Can replace with informative home page in the future. homePage() // HTTP POST request, receive a JSON object from another gossiper or connected monitor. // /gossip/push-data @@ -68,7 +70,10 @@ func initializeGossiperEndpoints(c *gossip.GossiperContext) { // MUX which routes HTTP directories to functions. gorillaRouter := mux.NewRouter().StrictSlash(true) - // homePage() is ran when base directory is accessed, this allows for confirmation that a gossiper is working as expected. + // basePage returns a 404 error as it is currently not intended to be directly accessed. + gorillaRouter.HandleFunc("/", basePage) + // homePage() is ran "/gossip/" is accessed, separated to allow development of an informative homepage in the future. + // Returns a 404 error as it is currently not intended to be directly accessed. gorillaRouter.HandleFunc("/gossip/", homePage) // Inter-gossiper endpoints: Post/Get required @@ -90,6 +95,12 @@ func initializeGossiperEndpoints(c *gossip.GossiperContext) { os.Exit(1) } +// Reply with a 404 error when "/" is accessed. +func basePage(w http.ResponseWriter, r *http.Request) { + http.Error(w, "Page not found.", http.StatusNotFound) +} + +// Reply with a 404 error when "/gossip/" is accessed. func homePage(w http.ResponseWriter, r *http.Request) { http.Error(w, "Page not found.", http.StatusNotFound) }