not use protobuf on context but use it on render (#1496)
This commit is contained in:
0
render/json.go
Executable file → Normal file
0
render/json.go
Executable file → Normal file
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type ProtoBuf struct {
|
||||
Data proto.Message
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
var protobufContentType = []string{"application/x-protobuf"}
|
||||
@ -19,7 +19,7 @@ var protobufContentType = []string{"application/x-protobuf"}
|
||||
func (r ProtoBuf) Render(w http.ResponseWriter) error {
|
||||
r.WriteContentType(w)
|
||||
|
||||
bytes, err := proto.Marshal(r.Data)
|
||||
bytes, err := proto.Marshal(r.Data.(proto.Message))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
0
render/render.go
Executable file → Normal file
0
render/render.go
Executable file → Normal file
3
render/render_test.go
Executable file → Normal file
3
render/render_test.go
Executable file → Normal file
@ -15,10 +15,11 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
testdata "github.com/gin-gonic/gin/testdata/protoexample"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/ugorji/go/codec"
|
||||
|
||||
testdata "github.com/gin-gonic/gin/testdata/protoexample"
|
||||
)
|
||||
|
||||
// TODO unit tests
|
||||
|
Reference in New Issue
Block a user