INNER CODE UNIT · Go

writeChallengeResponse

netgoat-xyz/netgoat · main.go:1298

func writeChallengeResponse(w http.ResponseWriter, r *http.Request, ch *challenge.Challenge, status int, fallback string) {
	if challenge.WantsJSON(r) {
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(status)
		_, _ = w.Write(challenge.RenderChallengeJSON(ch, status, fallback))
		return
	}
	html := challenge.RenderDynamicErrorPage(ch, status, fallback)
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	w.WriteHeader(status)
	_, _ = w.Write([]byte(html))
}

func challengeDifficulty(ch *challenge.Challenge) int {
	if ch == nil {
		return 0
	}
	return ch.Difficulty

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…