Response Parameters

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

Json Response Parameters

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