2021
05-28
05-28
解决Golang中ResponseWriter的一个坑
在使用Context.ResponseWriter中的Set/WriteHeader/Write这三个方法时,使用顺序必须如下所示,否则会出现某一设置不生效的情况。ctx.ResponseWriter.Header().Set("Content-type","application/text")ctx.ResponseWriter.WriteHeader(403)ctx.ResponseWriter.Write([]byte(resp))如1:ctx.ResponseWriter.Header().Set("Content-type","application/text")ctx.ResponseWriter.Write([]byte(resp))ctx.ResponseWriter.WriteH...
继续阅读 >