Skip to content

Response Body

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.

type Response struct {
Name string `json:"name"`
Age int `json:"age"`
}
resp := &Response{Name: "jack", Age: 18}
httpx.OkJson(w, resp)