Response Body
Overview
Section titled “Overview”In go-zero, the Write method of http.ResponseWriter is supported to return the response parameters, and the Header method of http.ResponseWriter is supported to return the response headersFor other response formats, see https://github.com/zeromicro/x/blob/main/http/responses.go , currently zeromicro/x implements an extension to xml.
Sample
Section titled “Sample”Json Response Parameters
Section titled “Json Response Parameters”type Response struct { Name string `json:"name"` Age int `json:"age"`}
resp := &Response{Name: "jack", Age: 18}httpx.OkJson(w, resp)