Documentation
¶
Index ¶
- Variables
- func HTTPStatusCodeToGRPCCode(code int) codes.Code
- type IStatus
- type Log
- type Meta
- type Response
- type ResponseBadRequest
- type ResponseErrorWithoutDetails
- type ResponseMeta
- func (*ResponseMeta) Descriptor() ([]byte, []int)deprecated
- func (x *ResponseMeta) GetLimit() int32
- func (x *ResponseMeta) GetPage() *ResponsePage
- func (x *ResponseMeta) GetTotal() int64
- func (*ResponseMeta) ProtoMessage()
- func (x *ResponseMeta) ProtoReflect() protoreflect.Message
- func (x *ResponseMeta) Reset()
- func (x *ResponseMeta) String() string
- type ResponsePage
- func (*ResponsePage) Descriptor() ([]byte, []int)deprecated
- func (x *ResponsePage) GetCurrent() int32
- func (x *ResponsePage) GetFirst() int32
- func (x *ResponsePage) GetLast() int32
- func (x *ResponsePage) GetNext() int32
- func (x *ResponsePage) GetPrevious() int32
- func (*ResponsePage) ProtoMessage()
- func (x *ResponsePage) ProtoReflect() protoreflect.Message
- func (x *ResponsePage) Reset()
- func (x *ResponsePage) String() string
- type ResponseStatus
- type ResponseStatusBadRequest
- type ResponseStatusWithoutDetails
- type ResponseSuccess
- type ResponseSuccessWithMeta
- type Status
- func NewStatusBadRequest(langCode, field, message, reason string, err error) *Status
- func NewStatusCode(code int) *Status
- func NewStatusData(code int, data any) *Status
- func NewStatusDataMeta(code int, data any, meta *Meta) *Status
- func NewStatusDetails(code int, message string, details ...protoadapt.MessageV1) *Status
- func NewStatusError(code int, err error) *Status
- func NewStatusMessage(code int, message string, err error) *Status
- func NewStatusMessageData(code int, message string, data any, err error) *Status
- func NewStatusSuccess(code int, message string, data any) *Status
- type StatusHolder
Constants ¶
This section is empty.
Variables ¶
View Source
var File_pkg_response_response_meta_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Response ¶
type Response struct {
Status ResponseStatus `json:"status"`
Data any `json:"data,omitempty"`
Meta *ResponseMeta `json:"meta,omitempty"`
}
type ResponseBadRequest ¶
type ResponseBadRequest struct {
Status ResponseStatusBadRequest `json:"status"`
}
type ResponseErrorWithoutDetails ¶
type ResponseErrorWithoutDetails struct {
Status ResponseStatusWithoutDetails `json:"status"`
}
type ResponseMeta ¶
type ResponseMeta struct {
Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total" example:"100"`
Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit" example:"10"`
Page *ResponsePage `protobuf:"bytes,3,opt,name=page,proto3" json:"page"`
// contains filtered or unexported fields
}
func ResponseMetaSetup ¶
func ResponseMetaSetup(total int64, limit, pageCurrent int32) *ResponseMeta
func (*ResponseMeta) Descriptor
deprecated
func (*ResponseMeta) Descriptor() ([]byte, []int)
Deprecated: Use ResponseMeta.ProtoReflect.Descriptor instead.
func (*ResponseMeta) GetLimit ¶
func (x *ResponseMeta) GetLimit() int32
func (*ResponseMeta) GetPage ¶
func (x *ResponseMeta) GetPage() *ResponsePage
func (*ResponseMeta) GetTotal ¶
func (x *ResponseMeta) GetTotal() int64
func (*ResponseMeta) ProtoMessage ¶
func (*ResponseMeta) ProtoMessage()
func (*ResponseMeta) ProtoReflect ¶
func (x *ResponseMeta) ProtoReflect() protoreflect.Message
func (*ResponseMeta) Reset ¶
func (x *ResponseMeta) Reset()
func (*ResponseMeta) String ¶
func (x *ResponseMeta) String() string
type ResponsePage ¶
type ResponsePage struct {
First int32 `protobuf:"varint,1,opt,name=first,proto3" json:"first" example:"1"`
Previous *int32 `protobuf:"varint,2,opt,name=previous,proto3,oneof" json:"previous" example:"2"`
Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current" example:"3"`
Next *int32 `protobuf:"varint,4,opt,name=next,proto3,oneof" json:"next" example:"4"`
Last int32 `protobuf:"varint,5,opt,name=last,proto3" json:"last" example:"9"`
// contains filtered or unexported fields
}
func ResponsePageSetup ¶
func ResponsePageSetup(total int64, limit, pageCurrent int32) *ResponsePage
func (*ResponsePage) Descriptor
deprecated
func (*ResponsePage) Descriptor() ([]byte, []int)
Deprecated: Use ResponsePage.ProtoReflect.Descriptor instead.
func (*ResponsePage) GetCurrent ¶
func (x *ResponsePage) GetCurrent() int32
func (*ResponsePage) GetFirst ¶
func (x *ResponsePage) GetFirst() int32
func (*ResponsePage) GetLast ¶
func (x *ResponsePage) GetLast() int32
func (*ResponsePage) GetNext ¶
func (x *ResponsePage) GetNext() int32
func (*ResponsePage) GetPrevious ¶
func (x *ResponsePage) GetPrevious() int32
func (*ResponsePage) ProtoMessage ¶
func (*ResponsePage) ProtoMessage()
func (*ResponsePage) ProtoReflect ¶
func (x *ResponsePage) ProtoReflect() protoreflect.Message
func (*ResponsePage) Reset ¶
func (x *ResponsePage) Reset()
func (*ResponsePage) String ¶
func (x *ResponsePage) String() string
type ResponseStatus ¶
type ResponseStatusBadRequest ¶
type ResponseStatusBadRequest struct {
Code string `json:"code" example:"400.1"`
Message string `json:"message" example:"Bad Request"`
Details []*errdetails.BadRequest `json:"details,omitempty"`
}
type ResponseSuccess ¶
type ResponseSuccess struct {
Status ResponseStatusWithoutDetails `json:"status"`
Data any `json:"data,omitempty"`
}
type ResponseSuccessWithMeta ¶
type ResponseSuccessWithMeta struct {
Status ResponseStatusWithoutDetails `json:"status"`
Data any `json:"data,omitempty"`
Meta *ResponseMeta `json:"meta,omitempty"`
}
type Status ¶
type Status struct {
// HTTP status codes as registered with IANA. See: https://go.dev/src/net/http/status.go
Code int `json:"code"`
// message for ui/ux
Message string `json:"message"`
// message for engineer
CauseError error `json:"cause_error"`
StackTrace []string `json:"stack_trace"`
Data any `json:"data"`
Meta *Meta `json:"meta"`
Details []protoadapt.MessageV1 `json:"details"`
Caller string `json:"caller"`
}
use this Status to wrap error across all apps including non http app
func NewStatusBadRequest ¶
func NewStatusCode ¶
func NewStatusData ¶
func NewStatusDetails ¶
func NewStatusDetails(code int, message string, details ...protoadapt.MessageV1) *Status
func NewStatusError ¶
func NewStatusMessageData ¶
func (*Status) BadRequests ¶
func (s *Status) BadRequests() []*errdetails.BadRequest
func (*Status) CauseErrorMessageOrDefault ¶
func (*Status) GRPCStatus ¶
func (*Status) MessageOrDefault ¶
type StatusHolder ¶
type StatusHolder struct {
Status *Status
}
Click to show internal directories.
Click to hide internal directories.