Documentation ¶
Index ¶
- Constants
- Variables
- func Language(r *http.Request) i18n.LanguageCodes
- func OrgID(r *http.Request) string
- func OrgName(r *http.Request) string
- func Success(data interface{}, status ...int) httpserver.ResponseGetter
- func SuccessRaw(data interface{}, status ...int) httpserver.ResponseGetter
- func UserID(r *http.Request) string
- type Error
- type ErrorCode
- type ErrorMessage
- type RawResponse
- type Response
- type TemplatedError
Constants ¶
View Source
const Errors errors = 0
Errors .
Variables ¶
View Source
var ( InvalidParameterError = &TemplatedError{http.StatusBadRequest, "Invalid Parameter", `${Invalid Parameter}: %s`, nil} MissingParameterError = &TemplatedError{http.StatusBadRequest, "MissingParameter", `${Missing Parameter}: %s`, nil} InvalidStateError = &TemplatedError{http.StatusBadRequest, "InvalidState", `${Invalid State}: %s`, nil} NotLoginError = &TemplatedError{http.StatusUnauthorized, "NotLogin", `${Not Login}`, nil} AccessDeniedError = &TemplatedError{http.StatusUnauthorized, "AccessDenied", `${Access Denied}`, nil} NotFoundError = &TemplatedError{http.StatusNotFound, "NotFound", `${Not Found}: %s`, nil} AlreadyExistsError = &TemplatedError{http.StatusBadRequest, "AlreadyExists", `${Already Exists}: %s`, nil} InternalError = &TemplatedError{http.StatusInternalServerError, "InternalError", `${Internal Error}: %s`, nil} )
common errors
View Source
var I18n i18n.I18n
I18n set by common package
Functions ¶
func SuccessRaw ¶
func SuccessRaw(data interface{}, status ...int) httpserver.ResponseGetter
SuccessRaw .
Types ¶
type Error ¶
type Error struct { Code interface{} `json:"code,omitempty"` Msg interface{} `json:"msg,omitempty"` Ctx interface{} `json:"ctx,omitempty"` }
Error .
type ErrorMessage ¶
type ErrorMessage interface {
Message(ctx httpserver.Context) string
}
ErrorMessage .
type RawResponse ¶
type RawResponse struct {
// contains filtered or unexported fields
}
RawResponse .
func (*RawResponse) Error ¶
func (r *RawResponse) Error(httpserver.Context) error
func (*RawResponse) ReadCloser ¶
func (r *RawResponse) ReadCloser(httpserver.Context) io.ReadCloser
func (*RawResponse) Response ¶
func (r *RawResponse) Response(ctx httpserver.Context) httpserver.Response
Response .
func (*RawResponse) Status ¶
func (r *RawResponse) Status(httpserver.Context) int
type Response ¶
type Response struct { Success bool `json:"success,omitempty"` Data interface{} `json:"data,omitempty"` Err *Error `json:"err,omitempty"` // contains filtered or unexported fields }
Response .
func Failure ¶
func Failure(code, msg interface{}, ctx ...interface{}) *Response
Failure code、msg、ctx
func (*Response) Error ¶
func (r *Response) Error(httpserver.Context) error
func (*Response) ReadCloser ¶
func (r *Response) ReadCloser(httpserver.Context) io.ReadCloser
func (*Response) Response ¶
func (r *Response) Response(ctx httpserver.Context) httpserver.Response
Response .
func (*Response) Status ¶
func (r *Response) Status(httpserver.Context) int
type TemplatedError ¶
type TemplatedError struct {
// contains filtered or unexported fields
}
TemplatedError .
func (*TemplatedError) Clone ¶
func (e *TemplatedError) Clone(args ...interface{}) *TemplatedError
Clone .
func (*TemplatedError) Message ¶
func (e *TemplatedError) Message(ctx httpserver.Context) string
Message .
Click to show internal directories.
Click to hide internal directories.