apis

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var I18n i18n.I18n

I18n .

Functions

func GetClientIP

func GetClientIP(ctx context.Context) string

GetClientIP

func GetContext

func GetContext(ctx context.Context, setHeader func(header *transport.Header)) context.Context

func GetHeader

func GetHeader(ctx context.Context, key string) string

GetHeader

func GetIdentityInfo

func GetIdentityInfo(ctx context.Context) *pb.IdentityInfo

GetIdentityInfo get User-ID, Internal-Client and Org-ID from header. return nil if no identity info found.

func GetIntOrgID

func GetIntOrgID(ctx context.Context) (int64, error)

GetIntOrgID .

func GetIntUserID

func GetIntUserID(ctx context.Context) (int64, error)

GetIntUserID .

func GetInternalClient

func GetInternalClient(ctx context.Context) string

func GetLang

func GetLang(ctx context.Context) string

GetLang .

func GetOrg

func GetOrg(ctx context.Context) string

GetOrg .

func GetOrgID

func GetOrgID(ctx context.Context) string

GetOrgID .

func GetUserID

func GetUserID(ctx context.Context) string

GetUserID .

func HTTPLanguage

func HTTPLanguage(r *http.Request) i18n.LanguageCodes

HTTPLanguage .

func IsInternalClient

func IsInternalClient(ctx context.Context) bool

func Language

func Language(ctx context.Context) i18n.LanguageCodes

Language .

func Options

func Options() transport.ServiceOption

Options .

func WithCustomHeaderContext

func WithCustomHeaderContext(ctx context.Context, header transport.Header) context.Context

func WithCustomHeaderKVContext

func WithCustomHeaderKVContext(ctx context.Context, kvs ...string) context.Context

func WithInternalClientContext

func WithInternalClientContext(ctx context.Context, internalClient string) context.Context

WithInternalClientContext .

func WithOrgIDContext

func WithOrgIDContext(ctx context.Context, orgID string) context.Context

func WithUserIDContext

func WithUserIDContext(ctx context.Context, userID string) context.Context

Types

type Error

type Error struct {
	Code interface{} `json:"code,omitempty"`
	Msg  interface{} `json:"msg,omitempty"`
	Ctx  interface{} `json:"ctx,omitempty"`
}

Error .

func (*Error) Error

func (s *Error) Error() string

type Response

type Response struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	UserIDs []string    `json:"userIDs,omitempty"`
	Err     *Error      `json:"err,omitempty"`
}

Response .

type ValidationError

type ValidationError interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
}

type Validator

type Validator interface {
	Validate() error
}

Define validator and error interface as all related struct in protoc-gen-validate are defined as text templates. i.e. https://github.com/envoyproxy/protoc-gen-validate/blob/main/templates/go/message.go

Jump to

Keyboard shortcuts

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