2 Star 2 Fork 0

jmash / jmash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
marshal_httpbody.go 1022 Bytes
一键复制 编辑 原始数据 按行查看 历史
百圆汽车保养 提交于 2024-01-01 23:10 . 换行符
package jmash
import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/genproto/googleapis/api/httpbody"
)
//自定义文件解析
type FileHttpBodyMarshaler struct {
runtime.Marshaler
}
// ContentType returns its specified content type in case v is a
// google.api.HttpBody message, otherwise it will fall back to the default Marshalers
// content type.
func (h *FileHttpBodyMarshaler) ContentType(v interface{}) string {
if httpBody, ok := v.(*httpbody.HttpBody); ok {
return httpBody.GetContentType()
}
return h.Marshaler.ContentType(v)
}
// Marshal marshals "v" by returning the body bytes if v is a
// google.api.HttpBody message, otherwise it falls back to the default Marshaler.
func (h *FileHttpBodyMarshaler) Marshal(v interface{}) ([]byte, error) {
if httpBody, ok := v.(*httpbody.HttpBody); ok {
return httpBody.GetData(), nil
}
return h.Marshaler.Marshal(v)
}
//分隔符设置未'',默认换行.
func (t *FileHttpBodyMarshaler)Delimiter() []byte {
return []byte("")
}
Java
1
https://gitee.com/jmash/jmash.git
git@gitee.com:jmash/jmash.git
jmash
jmash
jmash
74b440458984

搜索帮助

53164aa7 5694891 3bd8fe86 5694891