api

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 11 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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 Language

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

Language .

func OrgID

func OrgID(r *http.Request) string

OrgID .

func Success

func Success(data interface{}, status ...int) httpserver.ResponseGetter

Success .

func SuccessRaw

func SuccessRaw(data interface{}, status ...int) httpserver.ResponseGetter

SuccessRaw .

func UserID

func UserID(r *http.Request) string

UserID .

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 ErrorCode

type ErrorCode interface {
	Status() int
	Code() string
}

ErrorCode .

func CodedError

func CodedError(status int, code string) ErrorCode

CodedError .

type ErrorMessage

type ErrorMessage interface {
	Message(ctx httpserver.Context) string
}

ErrorMessage .

type RawResponse

type RawResponse struct {
	// contains filtered or unexported fields
}

RawResponse .

func (*RawResponse) Body

func (r *RawResponse) Body() interface{}

func (*RawResponse) Error

func (r *RawResponse) Error(httpserver.Context) error

func (*RawResponse) ReadCloser

func (r *RawResponse) ReadCloser(httpserver.Context) io.ReadCloser

func (*RawResponse) 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 OrgIDInt

func OrgIDInt(r *http.Request) (int64, *Response)

OrgIDInt .

func UserIDInt

func UserIDInt(r *http.Request) (int64, *Response)

UserIDInt .

func (*Response) Body

func (r *Response) Body() interface{}

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) Code

func (e *TemplatedError) Code() string

Code .

func (*TemplatedError) Message

func (e *TemplatedError) Message(ctx httpserver.Context) string

Message .

func (*TemplatedError) Status

func (e *TemplatedError) Status() int

Status .

Jump to

Keyboard shortcuts

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