mirror of
https://github.com/bvanroll/stage-backend.git
synced 2025-08-29 03:52:42 +00:00
added forced errors for fault injection
This commit is contained in:
12
src/main.go
12
src/main.go
@@ -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")
|
||||
}
|
Reference in New Issue
Block a user