Replies: 1 comment 1 reply
-
middleware.Handler的第二个参数不就是请求参数么 func MyMiddleware() middleware.Middleware {
return func(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (interface{}, error) {
// req 就是参数
return handler(ctx, req)
}
}
} HTTP请求的 Content-Type 没有规定必须要application/json。可以使用什么类型取决于程序启动时是否注册了相应的编解码器,默认支持的类型有 x-www-form-urlencoded、json、proto、xml、yaml 如果想支持其他的类型也很方便,只要实现kratos中的encoding.Codec接口,然后在框架启动时通过encoding.RegisterCodec()方法注册就行 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions