Skip to content

Commit

Permalink
add example of protobuf rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
salamer committed Aug 18, 2018
1 parent 02f2720 commit 9488723
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 9488723

Please sign in to comment.