Documentation ¶
Index ¶
- Variables
- type Message
- type Respond
- func (respond Respond) DeleteFailed() (int, interface{})
- func (respond Respond) DeleteSucceeded() (int, interface{})
- func (respond Respond) Error(statusCode int, errorCode int) (int, interface{})
- func (respond Respond) InsertFailed() (int, interface{})
- func (respond Respond) InsertSucceeded() (int, interface{})
- func (respond Respond) Message() *Message
- func (respond Respond) MethodNotAllowed() (int, interface{})
- func (respond Respond) NotFound() (int, interface{})
- func (respond Respond) RequestFieldDuplicated() (int, interface{})
- func (respond Respond) RequestFieldNotfound() (int, interface{})
- func (respond Respond) RespondWithMessage(message interface{}) (int, interface{})
- func (respond Respond) RespondWithResult(result interface{}) (int, interface{})
- func (respond Respond) SetErrorCode(code int) Respond
- func (respond Respond) SetStatusCode(code int) Respond
- func (respond Respond) SetStatusText(text string) Respond
- func (respond Respond) Succeed(data interface{}) (int, interface{})
- func (respond Respond) UpdateFailed() (int, interface{})
- func (respond Respond) UpdateSucceeded() (int, interface{})
- func (respond Respond) ValidationErrors(errors interface{}) (int, interface{})
- func (respond Respond) WrongParameters() (int, interface{})
Constants ¶
This section is empty.
Variables ¶
var Default = &Respond{}
var DefaultWithLang = func(lang string) *Respond { return &Respond{lang: lang} }
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { // language of response Lang string // success field of response Success string // failed field of response Failed string // respond error messages Errors map[string]map[string]interface{} }
func (*Message) LoadConfig ¶
Load config of response language
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return *Message
type Respond ¶
type Respond struct {
// contains filtered or unexported fields
}
func (Respond) DeleteFailed ¶
Delete action is failed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) DeleteSucceeded ¶
Delete action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) Error ¶
The error message
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @param statusCode int,errorCode string @return (statuscode int, result interface{})
func (Respond) InsertFailed ¶
Insert action is failed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) InsertSucceeded ¶
Insert action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) Message ¶
Get message type
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return *Message
func (Respond) MethodNotAllowed ¶
Wrong parameters are entered
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) NotFound ¶
return notfound result
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) RequestFieldDuplicated ¶
The request field is duplicated
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) RequestFieldNotfound ¶
The request field is not found
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) RespondWithMessage ¶
Pass response with message text as string
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @param message interface{} @return (statuscode int, result interface{})
func (Respond) RespondWithResult ¶
Pass response with result data like this array
array := map[string]interface{} { "status": respond.statusText, "result": result, }
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @param result map[string]interface{} @return (statuscode int, result interface{})
func (Respond) SetErrorCode ¶
Set status code of response and set default value as 0
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return Respond @param code int
func (Respond) SetStatusCode ¶
Set status code of response and set default value as 0
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return Respond @param code int
func (Respond) SetStatusText ¶
Set status text of response
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return Respond @param text string
func (Respond) Succeed ¶
return success result with data
data := map[string]interface{} { "data": "somedata" }
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @param data map[string]interface{} @return (statuscode int, result interface{})
func (Respond) UpdateFailed ¶
Update action is failed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) UpdateSucceeded ¶
Update action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})
func (Respond) ValidationErrors ¶
There ara validation translations
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @param translations map[string]interface{} @return (statuscode int, result interface{})
func (Respond) WrongParameters ¶
Wrong parameters are entered
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 15 Mar 2018 @return (statuscode int, result interface{})