Documentation ¶
Index ¶
- Constants
- Variables
- func HandleErr(w http.ResponseWriter, request *http.Request, logger *mylogger.MyLogger, ...)
- func SendResponse(w http.ResponseWriter, logger *mylogger.MyLogger, response Marshaller)
- type ErrorResponse
- type Marshaller
- type ResponseBody
- type ResponseBodyError
- type ResponseBodyID
- type ResponseBodyRedirect
- type ResponseID
- type ResponseRedirect
- type ResponseSuccessful
Constants ¶
const (
CookieAuthName = "access_token"
)
const (
ErrInternalServer = "Ошибка на сервере"
)
Variables ¶
var ErrCookieNotPresented = myerrors.NewErrorBadFormatRequest("Должна быть выставлена cookie, а её нет")
Functions ¶
func HandleErr ¶
HandleErr this function handle err. If err is myerror. Error then we built this error and client get it, otherwise it is internal error and client shouldn`t get it. Also hear added status in ctx of request
func SendResponse ¶
func SendResponse(w http.ResponseWriter, logger *mylogger.MyLogger, response Marshaller)
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Status int `json:"status"` Body ResponseBodyError `json:"body"` }
func NewErrResponse ¶
func NewErrResponse(status int, err string) *ErrorResponse
func (ErrorResponse) MarshalEasyJSON ¶
func (v ErrorResponse) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ErrorResponse) MarshalJSON ¶
func (v ErrorResponse) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ErrorResponse) UnmarshalEasyJSON ¶
func (v *ErrorResponse) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ErrorResponse) UnmarshalJSON ¶
func (v *ErrorResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type Marshaller ¶
type ResponseBody ¶
type ResponseBody struct {
Message string `json:"message"`
}
func (ResponseBody) MarshalEasyJSON ¶
func (v ResponseBody) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseBody) MarshalJSON ¶
func (v ResponseBody) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseBody) UnmarshalEasyJSON ¶
func (v *ResponseBody) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseBody) UnmarshalJSON ¶
func (v *ResponseBody) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ResponseBodyError ¶
type ResponseBodyError struct {
Error string `json:"error"`
}
func (ResponseBodyError) MarshalEasyJSON ¶
func (v ResponseBodyError) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseBodyError) MarshalJSON ¶
func (v ResponseBodyError) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseBodyError) UnmarshalEasyJSON ¶
func (v *ResponseBodyError) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseBodyError) UnmarshalJSON ¶
func (v *ResponseBodyError) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ResponseBodyID ¶
type ResponseBodyID struct {
ID uint64 `json:"id"`
}
func (ResponseBodyID) MarshalEasyJSON ¶
func (v ResponseBodyID) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseBodyID) MarshalJSON ¶
func (v ResponseBodyID) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseBodyID) UnmarshalEasyJSON ¶
func (v *ResponseBodyID) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseBodyID) UnmarshalJSON ¶
func (v *ResponseBodyID) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ResponseBodyRedirect ¶
type ResponseBodyRedirect struct {
RedirectURL string `json:"redirect_url"`
}
func (ResponseBodyRedirect) MarshalEasyJSON ¶
func (v ResponseBodyRedirect) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseBodyRedirect) MarshalJSON ¶
func (v ResponseBodyRedirect) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseBodyRedirect) UnmarshalEasyJSON ¶
func (v *ResponseBodyRedirect) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseBodyRedirect) UnmarshalJSON ¶
func (v *ResponseBodyRedirect) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ResponseID ¶
type ResponseID struct { Status int `example:"3003" json:"status"` Body ResponseBodyID `json:"body"` }
func NewResponseIDRedirect ¶
func NewResponseIDRedirect(id uint64) *ResponseID
func (ResponseID) MarshalEasyJSON ¶
func (v ResponseID) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseID) MarshalJSON ¶
func (v ResponseID) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseID) UnmarshalEasyJSON ¶
func (v *ResponseID) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseID) UnmarshalJSON ¶
func (v *ResponseID) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ResponseRedirect ¶
type ResponseRedirect struct { Status int `example:"3003" json:"status"` Body ResponseBodyRedirect `json:"body"` }
func NewResponseRedirect ¶
func NewResponseRedirect(redirectURL string) *ResponseRedirect
func (ResponseRedirect) MarshalEasyJSON ¶
func (v ResponseRedirect) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseRedirect) MarshalJSON ¶
func (v ResponseRedirect) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseRedirect) UnmarshalEasyJSON ¶
func (v *ResponseRedirect) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseRedirect) UnmarshalJSON ¶
func (v *ResponseRedirect) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type ResponseSuccessful ¶
type ResponseSuccessful struct { Status int `json:"status"` Body ResponseBody `json:"body"` }
func NewResponseSuccessful ¶
func NewResponseSuccessful(message string) *ResponseSuccessful
func (ResponseSuccessful) MarshalEasyJSON ¶
func (v ResponseSuccessful) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseSuccessful) MarshalJSON ¶
func (v ResponseSuccessful) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseSuccessful) UnmarshalEasyJSON ¶
func (v *ResponseSuccessful) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseSuccessful) UnmarshalJSON ¶
func (v *ResponseSuccessful) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface