I am messing around with a small go app for google app engine locally using the appengine sdk.
I have a problem where a path different than root can only be served if I try to hit it using localhost, but not a domain name.
My setup is as follows.
My app.yaml:
application: tasks
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
Minimum example code:
func init() {
fileHandler := http.FileServer(http.Dir("../frontend"))
http.HandleFunc("/loggedout", testHandler)
http.Handle("/", fileHandler)
log.Print(http.ListenAndServe(":8080", nil))
}
func testHandler(res http.ResponseWriter, req *http.Request){
panic("JUST NEED THIS TO WORK")
}
My symptoms is that if I access localhost:8080/ I get my website, and if I access localhost:8080/loggedout I get the expected panic.
If I access home.mydomain.com/ I get my website, however if I access home.mydomain.com/loggedout the connection just hangs, in chromes network tab it is listed as pending indefinitely.
As Greg pointed out, when I was using goapp I did not need to also call ListenAndServe. To get goapp to listen for requests outside of localhost I also had to add --host "my laptops ip" to the command.