// Copyright 2014 Manu Martinez-Almeida. All rights reserved.// Use of this source code is governed by a MIT style// license that can be found in the LICENSE file.packagebindingimport("io/ioutil""net/http""github.com/golang/protobuf/proto")typeprotobufBindingstruct{}func(protobufBinding)Name()string{return"protobuf"}func(bprotobufBinding)Bind(req*http.Request,objinterface{})error{buf,err:=ioutil.ReadAll(req.Body)iferr!=nil{returnerr}returnb.BindBody(buf,obj)}func(protobufBinding)BindBody(body[]byte,objinterface{})error{iferr:=proto.Unmarshal(body,obj.(proto.Message));err!=nil{returnerr}// Here it's same to return validate(obj), but util now we can't add// `binding:""` to the struct which automatically generate by gen-protoreturnnil// return validate(obj)}