Skip to content

Instantly share code, notes, and snippets.

@KauzClay
Created June 30, 2020 19:01
Show Gist options
  • Save KauzClay/0c499f2045f68d900f9e9afce0116572 to your computer and use it in GitHub Desktop.
Save KauzClay/0c499f2045f68d900f9e9afce0116572 to your computer and use it in GitHub Desktop.
failing app that will cause 502 bad gateway on gorouter
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