1 Star 0 Fork 0

凉夕 / generic-go-kit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
http.go 893 Bytes
一键复制 编辑 原始数据 按行查看 历史
凉夕 提交于 2024-01-04 14:10 . [Create] 初始化项目
package coder
import (
"context"
"github.com/nats-io/nats.go/micro"
"net/http"
)
// DecodeHttpRequestFunc
type DecodeHttpRequestFunc func(context.Context, *http.Request) (request interface{}, err error)
// EncodeHttpRequestFunc
type EncodeHttpRequestFunc func(context.Context, *http.Request, interface{}) error
// EncodeHttpResponseFunc
type EncodeHttpResponseFunc func(context.Context, http.ResponseWriter, interface{}) error
// DecodeHttpResponseFunc
type DecodeHttpResponseFunc func(context.Context, *http.Response) (response interface{}, err error)
// EncodeJSONToHttpRequest is an EncodeHttpRequestFunc that serializes the request as a
// JSON object to the Data of the Msg
func EncodeJSONToHttpRequest(_ context.Context, msg micro.Request, request interface{}) error {
//b, err := json.Marshal(request)
//if err != nil {
// return err
//}
//msg.Data = b
return nil
}
1
https://gitee.com/coldsunset/generic-go-kit.git
git@gitee.com:coldsunset/generic-go-kit.git
coldsunset
generic-go-kit
generic-go-kit
v0.0.1

搜索帮助