We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
main.go代码如下,演示如何对下列代码进行测试、压测及调优。
package main import ( "fmt" "log" "net/http" "regexp" ) var counter = map[string]int{} func handleHello(w http.ResponseWriter, r *http.Request) { color := r.FormValue("color") if match, _ := regexp.MatchString(`^[a-zA-Z]+$`, color); !match { http.Error(w, "Optional color is invalid", http.StatusBadRequest) return } name := r.FormValue("name") counter[name]++ w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Write([]byte("<h1 style='color: " + color + "'>Welcome!</h1> <p>Name: " + name + "</p> <p>Count: " + fmt.Sprint(counter[name]) + "</p>")) } func main() { http.HandleFunc("/hello", handleHello) log.Fatal(http.ListenAndServe(":8080", nil)) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
main.go代码如下,演示如何对下列代码进行测试、压测及调优。
The text was updated successfully, but these errors were encountered: