Created
June 30, 2020 19:01
-
-
Save KauzClay/0c499f2045f68d900f9e9afce0116572 to your computer and use it in GitHub Desktop.
failing app that will cause 502 bad gateway on gorouter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"os" | |
"time" | |
) | |
func main() { | |
http.HandleFunc("/", hello) | |
http.HandleFunc("/requesturi/", echo) | |
fmt.Println("listening...") | |
go func() { | |
time.Sleep(45 * time.Second) | |
panic("oh crap") | |
}() | |
err := http.ListenAndServe(":"+os.Getenv("PORT"), nil) | |
if err != nil { | |
panic(err) | |
} | |
} | |
func hello(res http.ResponseWriter, req *http.Request) { | |
fmt.Fprintln(res, "go, world") | |
} | |
func echo(res http.ResponseWriter, req *http.Request) { | |
fmt.Fprintln(res, fmt.Sprintf("Request URI is [%s]\nQuery String is [%s]", req.RequestURI, req.URL.RawQuery)) | |
panic("oops") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment