语言:http: superfluous response.WriteHeader call from"/>
Go语言:http: superfluous response.WriteHeader call from
在同一次请求响应过程中,只能调用一次WriteHeader(code int),否则会有一条日志输出“http: superfluous response.WriteHeader call from”。如下所示:
func handler(w http.ResponseWriter, r *http.Request) {w.Header().Set("Content-Type", "application/json; charset=utf-8")w.WriteHeader(200)w.WriteHeader(200) //重复调用fmt.Fprintf(w, "Hello")
}
更多推荐
Go语言:http: superfluous response.WriteHeader call from
发布评论