Created
May 4, 2025 15:25
-
-
Save msdousti/c64b772f1c10c0f12e44e51fa2aa7c7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
"math/rand" | |
"net/http" | |
"time" | |
) | |
func hello(w http.ResponseWriter, req *http.Request) { | |
if rand.Float64() < 0.1 { | |
http.Error(w, "Internal Server Error", http.StatusInternalServerError) | |
return | |
} else { | |
time.Sleep(time.Duration(rand.Intn(500)) * time.Millisecond) | |
fmt.Fprintf(w, "hello\n") | |
} | |
} | |
func main() { | |
http.HandleFunc("/", hello) | |
http.ListenAndServe(":8000", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment