Skip to main content

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

type Response struct {
Name string `json:"name"`
Age int `json:"age"`
}

resp := &Response{Name: "jack", Age: 18}
httpx.OkJson(w, resp)