Documentation ¶
Index ¶
- Constants
- Variables
- func ClientLog(logHelper *log.Helper) middleware.Middleware
- func ContentSubtype(contentType string) string
- func ContentType(subtype string) string
- func CustomErrorResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, err error)
- func CustomResponseDecoder(ctx context.Context, res *stdhttp.Response, v interface{}) error
- func CustomSuccessResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, v interface{}) error
- func DeleteDataTypeURL(buf []byte) ([]byte, error)
- func ErrorResponseDecode(ctx context.Context, res *stdhttp.Response) error
- func ErrorResponseDecodeBody(contentType string, statusCode int, data []byte) (*errors.Error, error)
- func ErrorResponseDecodeBody2(header stdhttp.Header, statusCode int, data []byte) (*errors.Error, error)
- func ErrorResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, err error)
- func IsDebugMode() bool
- func IsLocalMode() bool
- func IsSuccessCode(code int32) bool
- func IsSuccessGRPCCode(code uint32) bool
- func IsSuccessHTTPCode(code int) bool
- func MarshalJSON(v interface{}) ([]byte, error)
- func RegisterCodec()
- func RequestDecoder(r *http.Request, v interface{}) error
- func ServerLog(logHelper *log.Helper, opts ...Option) middleware.Middleware
- func SetJSONMarshalOptions(opt *protojson.MarshalOptions)
- func SetJSONUnmarshalOptions(opt *protojson.UnmarshalOptions)
- func SetMaxRequestArgSize(size uint)
- func SetResponseContentType(w stdhttp.ResponseWriter, codec encoding.Codec)
- func SetRuntimeEnv(env RuntimeEnvEnum_RuntimeEnv)
- func SuccessResponseDecoder(ctx context.Context, res *stdhttp.Response, v interface{}) error
- func SuccessResponseDecoderBody(contentType string, data []byte, v interface{}) error
- func SuccessResponseDecoderBody2(header stdhttp.Header, data []byte, v interface{}) error
- func SuccessResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, v interface{}) error
- func ToResponseError(response HTTPResponseInterface) *errors.Error
- func UnmarshalJSON(data []byte, v interface{}) error
- type ErrMessage
- type HTTPResponse
- type HTTPResponseInterface
- type Option
- type RequestMessage
- type Response
- func (*Response) Descriptor() ([]byte, []int)deprecated
- func (x *Response) GetCode() int32
- func (x *Response) GetData() *anypb.Any
- func (x *Response) GetMessage() string
- func (x *Response) GetMetadata() map[string]string
- func (x *Response) GetReason() string
- func (x *Response) GetRequestId() string
- func (*Response) ProtoMessage()
- func (x *Response) ProtoReflect() protoreflect.Message
- func (x *Response) Reset()
- func (x *Response) String() string
- type ResponseData
- type RuntimeEnvEnum
- type RuntimeEnvEnum_RuntimeEnv
- func (RuntimeEnvEnum_RuntimeEnv) Descriptor() protoreflect.EnumDescriptor
- func (x RuntimeEnvEnum_RuntimeEnv) Enum() *RuntimeEnvEnum_RuntimeEnv
- func (RuntimeEnvEnum_RuntimeEnv) EnumDescriptor() ([]byte, []int)deprecated
- func (x RuntimeEnvEnum_RuntimeEnv) Number() protoreflect.EnumNumber
- func (x RuntimeEnvEnum_RuntimeEnv) String() string
- func (RuntimeEnvEnum_RuntimeEnv) Type() protoreflect.EnumType
Constants ¶
const (
DefaultUploadMaxSize = 20 << 20 // 20M
)
const (
OK = 0
)
Variables ¶
var ( RuntimeEnvEnum_RuntimeEnv_name = map[int32]string{ 0: "UNKNOWN", 10: "LOCAL", 20: "DEVELOP", 30: "TESTING", 40: "UAT", 50: "PREVIEW", 60: "PRODUCTION", } RuntimeEnvEnum_RuntimeEnv_value = map[string]int32{ "UNKNOWN": 0, "LOCAL": 10, "DEVELOP": 20, "TESTING": 30, "UAT": 40, "PREVIEW": 50, "PRODUCTION": 60, } )
Enum value maps for RuntimeEnvEnum_RuntimeEnv.
var ( // MarshalOptions is a configurable JSON format marshaller. MarshalOptions = protojson.MarshalOptions{ EmitUnpopulated: true, } // UnmarshalOptions is a configurable JSON format parser. UnmarshalOptions = protojson.UnmarshalOptions{ DiscardUnknown: true, } )
var File_kratos_app_app_kit_proto protoreflect.FileDescriptor
Functions ¶
func ClientLog ¶
func ClientLog(logHelper *log.Helper) middleware.Middleware
ClientLog is an client logging middleware. logging.Client(logger)
func ContentSubtype ¶
ContentSubtype returns the content-subtype for the given content-type. The given content-type must be a valid content-type that starts with but no content-subtype will be returned. according rfc7231. contentType is assumed to be lowercase already.
func ContentType ¶
ContentType returns the content-type with base prefix.
func CustomErrorResponseEncoder ¶
func CustomErrorResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, err error)
CustomErrorResponseEncoder http.DefaultErrorEncoder
func CustomResponseDecoder ¶
CustomResponseDecoder http.DefaultResponseDecoder
func CustomSuccessResponseEncoder ¶
func CustomSuccessResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, v interface{}) error
CustomSuccessResponseEncoder http.DefaultResponseEncoder
func ErrorResponseDecode ¶
ErrorResponseDecode ...
func ErrorResponseDecodeBody ¶
func ErrorResponseDecodeBody(contentType string, statusCode int, data []byte) (*errors.Error, error)
ErrorResponseDecodeBody ...
func ErrorResponseDecodeBody2 ¶
func ErrorResponseDecodeBody2(header stdhttp.Header, statusCode int, data []byte) (*errors.Error, error)
ErrorResponseDecodeBody2 ...
func ErrorResponseEncoder ¶
func ErrorResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, err error)
ErrorResponseEncoder http.DefaultErrorEncoder
func ServerLog ¶
func ServerLog(logHelper *log.Helper, opts ...Option) middleware.Middleware
ServerLog 中间件日志 参考 logging.Server(logger)
func SetJSONMarshalOptions ¶
func SetJSONMarshalOptions(opt *protojson.MarshalOptions)
SetJSONMarshalOptions 设置json编码选项
func SetJSONUnmarshalOptions ¶
func SetJSONUnmarshalOptions(opt *protojson.UnmarshalOptions)
SetJSONUnmarshalOptions 设置json编码选项
func SetResponseContentType ¶
func SetResponseContentType(w stdhttp.ResponseWriter, codec encoding.Codec)
SetResponseContentType ...
func SuccessResponseDecoder ¶
SuccessResponseDecoder http.DefaultResponseDecoder
func SuccessResponseDecoderBody ¶
SuccessResponseDecoderBody http.DefaultResponseDecoder
func SuccessResponseDecoderBody2 ¶
SuccessResponseDecoderBody2 http.DefaultResponseDecoder
func SuccessResponseEncoder ¶
func SuccessResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, v interface{}) error
SuccessResponseEncoder http.DefaultResponseEncoder
func ToResponseError ¶
func ToResponseError(response HTTPResponseInterface) *errors.Error
ToResponseError 转换为错误
Types ¶
type ErrMessage ¶
ErrMessage 响应信息
type HTTPResponse ¶
type HTTPResponse struct { Code int32 `json:"code"` Reason string `json:"reason"` Message string `json:"message"` Metadata map[string]string `json:"metadata,omitempty"` Data interface{} `json:"data"` }
HTTPResponse 响应 关联更新 apppkg.Response
func CustomDecodeHTTPResponse ¶
func CustomDecodeHTTPResponse(contentBody []byte, data interface{}) (response *HTTPResponse, err error)
CustomDecodeHTTPResponse 解码结果
func (*HTTPResponse) GetCode ¶
func (x *HTTPResponse) GetCode() int32
func (*HTTPResponse) GetMessage ¶
func (x *HTTPResponse) GetMessage() string
func (*HTTPResponse) GetMetadata ¶
func (x *HTTPResponse) GetMetadata() map[string]string
func (*HTTPResponse) GetReason ¶
func (x *HTTPResponse) GetReason() string
type HTTPResponseInterface ¶
type HTTPResponseInterface interface { GetCode() int32 GetReason() string GetMessage() string GetMetadata() map[string]string }
HTTPResponseInterface .
type RequestMessage ¶
type RequestMessage struct { Kind string Component string Method string Operation string ExecTime time.Duration ClientIP string }
RequestMessage 请求信息
func (*RequestMessage) GetOperationInfo ¶
func (s *RequestMessage) GetOperationInfo() string
GetOperationInfo .
func (*RequestMessage) GetRequestInfo ¶
func (s *RequestMessage) GetRequestInfo() string
GetRequestInfo 获取服务信息
type Response ¶
type Response struct { Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"` Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` RequestId string `protobuf:"bytes,4,opt,name=requestId,proto3" json:"requestId,omitempty"` Data *anypb.Any `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` Metadata map[string]string `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
Response 响应
func CustomDecodeProtobufResponse ¶
func CustomDecodeProtobufResponse(contentBody []byte, pbMessage proto.Message) (response *Response, err error)
CustomDecodeProtobufResponse 解码结果
func CustomDecodeResponseError ¶
CustomDecodeResponseError 解码结果
func (*Response) Descriptor
deprecated
func (*Response) GetMessage ¶
func (*Response) GetMetadata ¶
func (*Response) GetRequestId ¶
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type ResponseData ¶
type ResponseData struct { Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
ResponseData data
func (*ResponseData) Descriptor
deprecated
func (*ResponseData) Descriptor() ([]byte, []int)
Deprecated: Use ResponseData.ProtoReflect.Descriptor instead.
func (*ResponseData) GetData ¶
func (x *ResponseData) GetData() string
func (*ResponseData) ProtoMessage ¶
func (*ResponseData) ProtoMessage()
func (*ResponseData) ProtoReflect ¶
func (x *ResponseData) ProtoReflect() protoreflect.Message
func (*ResponseData) Reset ¶
func (x *ResponseData) Reset()
func (*ResponseData) String ¶
func (x *ResponseData) String() string
type RuntimeEnvEnum ¶
type RuntimeEnvEnum struct {
// contains filtered or unexported fields
}
RuntimeEnvEnum app运行环境
func (*RuntimeEnvEnum) Descriptor
deprecated
func (*RuntimeEnvEnum) Descriptor() ([]byte, []int)
Deprecated: Use RuntimeEnvEnum.ProtoReflect.Descriptor instead.
func (*RuntimeEnvEnum) ProtoMessage ¶
func (*RuntimeEnvEnum) ProtoMessage()
func (*RuntimeEnvEnum) ProtoReflect ¶
func (x *RuntimeEnvEnum) ProtoReflect() protoreflect.Message
func (*RuntimeEnvEnum) Reset ¶
func (x *RuntimeEnvEnum) Reset()
func (*RuntimeEnvEnum) String ¶
func (x *RuntimeEnvEnum) String() string
type RuntimeEnvEnum_RuntimeEnv ¶
type RuntimeEnvEnum_RuntimeEnv int32
const ( // UNKNOWN 未知 RuntimeEnvEnum_UNKNOWN RuntimeEnvEnum_RuntimeEnv = 0 // LOCAL 本地开发 RuntimeEnvEnum_LOCAL RuntimeEnvEnum_RuntimeEnv = 10 // DEVELOP 开发环境 RuntimeEnvEnum_DEVELOP RuntimeEnvEnum_RuntimeEnv = 20 // TESTING 测试环境 RuntimeEnvEnum_TESTING RuntimeEnvEnum_RuntimeEnv = 30 // UAT User Acceptance Test RuntimeEnvEnum_UAT RuntimeEnvEnum_RuntimeEnv = 40 // PREVIEW 预发布 环境 RuntimeEnvEnum_PREVIEW RuntimeEnvEnum_RuntimeEnv = 50 // PRODUCTION 生产环境 RuntimeEnvEnum_PRODUCTION RuntimeEnvEnum_RuntimeEnv = 60 )
func (RuntimeEnvEnum_RuntimeEnv) Descriptor ¶
func (RuntimeEnvEnum_RuntimeEnv) Descriptor() protoreflect.EnumDescriptor
func (RuntimeEnvEnum_RuntimeEnv) Enum ¶
func (x RuntimeEnvEnum_RuntimeEnv) Enum() *RuntimeEnvEnum_RuntimeEnv
func (RuntimeEnvEnum_RuntimeEnv) EnumDescriptor
deprecated
func (RuntimeEnvEnum_RuntimeEnv) EnumDescriptor() ([]byte, []int)
Deprecated: Use RuntimeEnvEnum_RuntimeEnv.Descriptor instead.
func (RuntimeEnvEnum_RuntimeEnv) Number ¶
func (x RuntimeEnvEnum_RuntimeEnv) Number() protoreflect.EnumNumber
func (RuntimeEnvEnum_RuntimeEnv) String ¶
func (x RuntimeEnvEnum_RuntimeEnv) String() string
func (RuntimeEnvEnum_RuntimeEnv) Type ¶
func (RuntimeEnvEnum_RuntimeEnv) Type() protoreflect.EnumType