I've been testing out the Google App Engine SDK using Golang and I'm having issues serving a static html page. If I add the content in the app.yaml
under handlers that is fine but when trying to route it from inside my Go application; trying out the url http://localhost:8080/tr
the page returns 404.
My file system is setup as:
/main.go
/app.yaml
/testRoute.html
My main app.go
looks like this:
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func init() {
r := mux.NewRouter()
r.HandleFunc("/", index)
r.HandleFunc("/tr", testRoute)
http.Handle("/", r)
}
func index(w http.ResponseWriter, r *http.Request) {
//No Issues here
fmt.Fprint(w, "Main Index.")
}
func testRoute(w http.ResponseWriter, r *http.Request) {
http.FileServer(http.Dir("testRoute.html")).ServeHTTP(w, r)
}