diff --git a/README.md b/README.md index 161ea28b..fa571224 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi - [Bind Query String or Post Data](#bind-query-string-or-post-data) - [Bind HTML checkboxes](#bind-html-checkboxes) - [Multipart/Urlencoded binding](#multiparturlencoded-binding) - - [XML, JSON and YAML rendering](#xml-json-and-yaml-rendering) + - [XML, JSON, YAML and ProtoBuf rendering](#xml-json-yaml-and-protobuf-rendering) - [JSONP rendering](#jsonp) - [Serving static files](#serving-static-files) - [Serving data from reader](#serving-data-from-reader) @@ -871,7 +871,7 @@ Test it with: $ curl -v --form user=user --form password=password http://localhost:8080/login ``` -### XML, JSON and YAML rendering +### XML, JSON, YAML and ProtoBuf rendering ```go func main() { @@ -905,6 +905,18 @@ func main() { c.YAML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK}) }) + r.GET("/someProtoBuf", func(c *gin.Context) { + reps := []int64{int64(1), int64(2)} + label := "test" + + // Proto specifically defines the testdata/protoexample file + data := &protoexample.Test{ + Label: &label, + Reps: reps, + } + c.ProtoBuf(http.StatusOK, data) + }) + // Listen and serve on 0.0.0.0:8080 r.Run(":8080") } diff --git a/context_test.go b/context_test.go index c380db6c..675c2a49 100644 --- a/context_test.go +++ b/context_test.go @@ -971,7 +971,7 @@ func TestContextRenderProtoBuf(t *testing.T) { Reps: reps, } - c.ProtoBuf(201, data) + c.ProtoBuf(http.StatusCreated, data) protoData, err := proto.Marshal(data) assert.NoError(t, err)