apppkg

package
v0.2.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 29 Imported by: 3

README

app

kratos proto client ./kratos/app/app.kit.proto

Documentation

Index

Constants

View Source
const (
	DefaultUploadMaxSize = 20 << 20 // 20M
)
View Source
const (
	OK = 0
)

Variables

View Source
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.

View Source
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,
	}
)
View Source
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

func ContentSubtype(contentType string) string

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

func ContentType(subtype string) string

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

func CustomResponseDecoder(ctx context.Context, res *stdhttp.Response, v interface{}) error

CustomResponseDecoder http.DefaultResponseDecoder

func CustomSuccessResponseEncoder

func CustomSuccessResponseEncoder(w stdhttp.ResponseWriter, r *stdhttp.Request, v interface{}) error

CustomSuccessResponseEncoder http.DefaultResponseEncoder

func DeleteDataTypeURL

func DeleteDataTypeURL(buf []byte) ([]byte, error)

DeleteDataTypeURL ...

func ErrorResponseDecode

func ErrorResponseDecode(ctx context.Context, res *stdhttp.Response) error

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 IsDebugMode

func IsDebugMode() bool

IsDebugMode ...

func IsLocalMode

func IsLocalMode() bool

IsLocalMode ...

func IsSuccessCode

func IsSuccessCode(code int32) bool

IsSuccessCode 成功的响应码

func IsSuccessGRPCCode

func IsSuccessGRPCCode(code uint32) bool

IsSuccessGRPCCode 成功的GRPC响应吗

func IsSuccessHTTPCode

func IsSuccessHTTPCode(code int) bool

IsSuccessHTTPCode 成功的HTTP响应吗

func MarshalJSON

func MarshalJSON(v interface{}) ([]byte, error)

MarshalJSON 编码json

func RegisterCodec

func RegisterCodec()

RegisterCodec ...

func RequestDecoder

func RequestDecoder(r *http.Request, v interface{}) error

RequestDecoder ...

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 SetMaxRequestArgSize

func SetMaxRequestArgSize(size uint)

SetMaxRequestArgSize 设置最大请求参数

func SetResponseContentType

func SetResponseContentType(w stdhttp.ResponseWriter, codec encoding.Codec)

SetResponseContentType ...

func SetRuntimeEnv

func SetRuntimeEnv(env RuntimeEnvEnum_RuntimeEnv)

SetRuntimeEnv ...

func SuccessResponseDecoder

func SuccessResponseDecoder(ctx context.Context, res *stdhttp.Response, v interface{}) error

SuccessResponseDecoder http.DefaultResponseDecoder

func SuccessResponseDecoderBody

func SuccessResponseDecoderBody(contentType string, data []byte, v interface{}) error

SuccessResponseDecoderBody http.DefaultResponseDecoder

func SuccessResponseDecoderBody2

func SuccessResponseDecoderBody2(header stdhttp.Header, data []byte, v interface{}) error

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 转换为错误

func UnmarshalJSON

func UnmarshalJSON(data []byte, v interface{}) error

UnmarshalJSON 解码json

Types

type ErrMessage

type ErrMessage struct {
	Code   int32
	Reason string
	Msg    string
	Stack  string

	RequestArgs string
}

ErrMessage 响应信息

func (*ErrMessage) GetErrorDetail

func (s *ErrMessage) GetErrorDetail() string

GetErrorDetail ...

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 Option

type Option func(options *options)

Option ...

func WithCallerSkip

func WithCallerSkip(skip int) Option

WithCallerSkip ...

func WithDefaultSkip

func WithDefaultSkip() Option

WithDefaultSkip ...

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

func CustomDecodeResponseError(contentBody []byte) (response *Response, err error)

CustomDecodeResponseError 解码结果

func (*Response) Descriptor deprecated

func (*Response) Descriptor() ([]byte, []int)

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetCode

func (x *Response) GetCode() int32

func (*Response) GetData

func (x *Response) GetData() *anypb.Any

func (*Response) GetMessage

func (x *Response) GetMessage() string

func (*Response) GetMetadata

func (x *Response) GetMetadata() map[string]string

func (*Response) GetReason

func (x *Response) GetReason() string

func (*Response) GetRequestId

func (x *Response) GetRequestId() string

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

func (x *Response) ProtoReflect() protoreflect.Message

func (*Response) Reset

func (x *Response) Reset()

func (*Response) String

func (x *Response) String() string

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 GetRuntimeEnv

func GetRuntimeEnv() RuntimeEnvEnum_RuntimeEnv

GetRuntimeEnv ...

func ParseEnv

func ParseEnv(appEnv string) RuntimeEnvEnum_RuntimeEnv

ParseEnv ...

func (RuntimeEnvEnum_RuntimeEnv) Descriptor

func (RuntimeEnvEnum_RuntimeEnv) Enum

func (RuntimeEnvEnum_RuntimeEnv) EnumDescriptor deprecated

func (RuntimeEnvEnum_RuntimeEnv) EnumDescriptor() ([]byte, []int)

Deprecated: Use RuntimeEnvEnum_RuntimeEnv.Descriptor instead.

func (RuntimeEnvEnum_RuntimeEnv) Number

func (RuntimeEnvEnum_RuntimeEnv) String

func (x RuntimeEnvEnum_RuntimeEnv) String() string

func (RuntimeEnvEnum_RuntimeEnv) Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL