Documentation
¶
Index ¶
- func ApiRequestCtx(c context.Context, api string) context.Context
- func Contextual(ctx context.Context, errs ...error) []zap.Field
- func FourZeroFour() http.Handler
- func GetApiName(ctx context.Context) string
- func GetClientID(ctx context.Context) string
- func GetClientSecret(ctx context.Context) string
- func GetHost(ctx context.Context) string
- func GetRequestID(ctx context.Context) string
- func GetToken(ctx context.Context) string
- func GetUserID(ctx context.Context) string
- func HandleError(ctx context.Context, w http.ResponseWriter, err error)
- func HandleInternalError(ctx context.Context, w http.ResponseWriter, err error)
- func ReadRequestBody(ctx context.Context, r *http.Request, out interface{}) error
- type ApiError
- func (e ApiError) Error() string
- func (e *ApiError) Unwrap() error
- func (e *ApiError) WithApiCode(code string) *ApiError
- func (e *ApiError) WithApiName(api string) *ApiError
- func (e *ApiError) WithCause(cause *ApiError) *ApiError
- func (e *ApiError) WithMessage(msg string) *ApiError
- func (e *ApiError) WithRequestId(rid string) *ApiError
- type ApiFoul
- func (f ApiFoul) Error() string
- func (e *ApiFoul) UnWrap() error
- func (f *ApiFoul) WithApiName(name string) *ApiFoul
- func (f *ApiFoul) WithCause(cause error) *ApiFoul
- func (f *ApiFoul) WithDomainCode(code string) *ApiFoul
- func (f *ApiFoul) WithMessage(msg string) *ApiFoul
- func (f *ApiFoul) WithStatusCode(status int) *ApiFoul
- type ApiHandler
- type ContextKey
- type ErrorResponse
- type OkResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FourZeroFour ¶
func GetApiName ¶
func GetClientID ¶
func GetClientSecret ¶
func GetRequestID ¶
func HandleError ¶
func HandleError(ctx context.Context, w http.ResponseWriter, err error)
func HandleInternalError ¶
func HandleInternalError(ctx context.Context, w http.ResponseWriter, err error)
Types ¶
type ApiError ¶ added in v0.0.3
type ApiError struct {
Message string `json:"message"`
ApiCode string `json:"api_code"`
ApiName string `json:"api_name"`
RequestId string `json:"request_id"`
Cause error `json:"-"`
StatusCode int `json:"status_code"`
Errors map[string]string `json:"errors"`
}
func NewApiError ¶ added in v0.0.3
func (*ApiError) WithApiCode ¶ added in v0.0.3
func (*ApiError) WithApiName ¶ added in v0.0.3
func (*ApiError) WithMessage ¶ added in v0.0.3
func (*ApiError) WithRequestId ¶ added in v0.0.3
type ApiFoul ¶
type ApiFoul struct {
ApiName string `json:"api_name"`
Message string `json:"message"`
Cause error `json:"-"`
RequestId string `json:"request_id"`
StatusCode int `json:"status_code"`
DomainCode string `json:"domain_codes"`
}
func (*ApiFoul) WithApiName ¶
func (*ApiFoul) WithDomainCode ¶
func (*ApiFoul) WithMessage ¶
func (*ApiFoul) WithStatusCode ¶
type ApiHandler ¶
type ApiHandler struct {
Name string
Path string
Method string
HandleFunc http.HandlerFunc
}
func (ApiHandler) RegisterToRouter ¶
func (api ApiHandler) RegisterToRouter(router *mux.Router)
type ContextKey ¶
type ContextKey int
const ( ApiName ContextKey = iota Token ClientID ClientSecret RequestID UserID Host )
type ErrorResponse ¶
type OkResponse ¶
type OkResponse struct {
Status string `json:"status"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.