added forced errors for fault injection

This commit is contained in:
2020-03-25 14:30:14 +01:00
parent 8606807158
commit 615ed7b666

View File

@@ -3,13 +3,25 @@ package main
import (
"fmt"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", HelloServer)
http.HandleFunc("/err/500", errorInternal)
http.HandleFunc("/err/timeout", errorTimeout)
http.ListenAndServe(":80", nil)
}
func HelloServer(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "{\"serverName\":\"backend-server\",\"success:false\",\"version\": \"experimental\"}")
}
func errorInternal(w http.ResponseWriter, r *http.Request) {
panic(500)
}
func errorTimeout(w http.ResponseWriter, r *http.Request) {
time.Sleep(2 * time.Second)
fmt.Fprintf(w, "this was delayed by 2 seconds")
}