// gin.H은 map[string]interface{} 타입입니다.
router.GET("/someJSON", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
router.GET("/moreJSON", func(c *gin.Context) {
Name string `json:"user"`
// msg.Name은 JSON에서 "user"가 됩니다.
// 출력내용 : {"user": "Lena", "Message": "hey", "Number": 123}
c.JSON(http.StatusOK, msg)
router.GET("/someXML", func(c *gin.Context) {
c.XML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
router.GET("/someYAML", func(c *gin.Context) {
c.YAML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
router.GET("/someProtoBuf", func(c *gin.Context) {
reps := []int64{int64(1), int64(2)}
// protobuf의 정의는 testdata/protoexample 파일에 작성되어 있습니다.
data := &protoexample.Test{
// 데이터는 응답(response)시에 이진 데이터가 됩니다.
// protobuf로 직렬화된 protoexample.Test가 출력됩니다.
c.ProtoBuf(http.StatusOK, data)
// 서버가 실행 되고 0.0.0.0:8080 에서 요청을 기다립니다.