Documentation ¶
Index ¶
- func JsonapiCustomError(statusCode int, status, source, title, detail *string) (int, interface{})
- func JsonapiErrorResp(status int, msg string) (int, interface{})
- func JsonapiErrorsResp(status int, msges ...string) (int, interface{})
- func JsonapiResourceResp(status int, resType, resID string, attr interface{}) (int, interface{})
- func JsonapiResourcesResp(status int, resType, resID string, metaData interface{}, attrs ...interface{}) (int, interface{})
- func Log(logD LoggingData, level, event, msg string)
- func LogNew(level, event, msg string)
- func MountRoute(router *gin.RouterGroup)
- type IncludeItem
- type ItemDataGen
- type JsonapiCreateEntityBody
- type JsonapiDataGen
- type JsonapiError
- type JsonapiErrorItem
- type LoggingData
- type Meta
- type Relationships
- type RelationshipsUser
- type RelationshipsUserData
- type SampleEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JsonapiCustomError ¶
JsonapiCustomError single error
func JsonapiErrorResp ¶
JsonapiErrorResp single error json api body
func JsonapiErrorsResp ¶
JsonapiErrorsResp multiple error json api body
func JsonapiResourceResp ¶
JsonapiResourceResp a generic jsonapi resource response with "type" and "id"
func JsonapiResourcesResp ¶
func JsonapiResourcesResp(status int, resType, resID string, metaData interface{}, attrs ...interface{}) (int, interface{})
JsonapiResourcesResp a generic jsonapi multiple resource response with "type" and "id"
func MountRoute ¶
func MountRoute(router *gin.RouterGroup)
MountRoute func will mount all rest routes
Types ¶
type IncludeItem ¶
type IncludeItem struct { Type string `json:"type"` Attributes interface{} `json:"attributes"` }
IncludeItem included item for jsonapi
type ItemDataGen ¶
type ItemDataGen struct { Type string `json:"type"` ID string `json:"id"` Attributes interface{} `json:"attributes"` }
ItemDataGen General
type JsonapiCreateEntityBody ¶
type JsonapiCreateEntityBody struct { Data struct { Type string `json:"type"` ID string `json:"id"` Attributes SampleEntity `json:"attributes"` Relationships Relationships `json:"relationships" binding:"required"` } `json:"data"` }
JsonapiCreateEntityBody jsonapi.org top wrap for request
type JsonapiDataGen ¶
type JsonapiDataGen struct { Data []*ItemDataGen `json:"data"` Meta interface{} `json:"meta"` }
JsonapiDataGen jsonapi.org top wrap
type JsonapiError ¶
type JsonapiError struct {
APIErrors []*JsonapiErrorItem `json:"errors"`
}
JsonapiError jsonapi.org error item
type JsonapiErrorItem ¶
type JsonapiErrorItem struct { Status string `json:"status"` Source string `json:"source"` Title string `json:"title"` Detail string `json:"detail"` }
JsonapiErrorItem jsonapi.org error wrap
type LoggingData ¶
type LoggingData struct { Timestamp string `json:"@timestamp,omitempty"` Service string `json:"service,omitempty"` Thread string `json:"thread,omitempty"` IP string `json:"ip,omitempty"` Env string `json:"env,omitempty"` Server string `json:"server,omitempty"` Level string `json:"level,omitempty"` Event string `json:"event,omitempty"` Message string `json:"message,omitempty"` ID string `json:"Id,omitempty"` Raw string `json:"raw,omitempty"` RawInterface interface{} `json:"rawInterface,omitempty"` }
LoggingData struct for structured loggin
type Relationships ¶
type Relationships struct {
User RelationshipsUser `json:"user"`
}
Relationships user data
type RelationshipsUser ¶
type RelationshipsUser struct {
Data RelationshipsUserData `json:"data"`
}
RelationshipsUser user data
type RelationshipsUserData ¶
type RelationshipsUserData struct { Type string `json:"type"` ID string `json:"id" binding:"required"` }
RelationshipsUserData user data
type SampleEntity ¶
type SampleEntity struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` UserID string `json:"userid,omitempty" binding:"required"` Created time.Time `json:"created,omitempty"` Updated time.Time `json:"updated,omitempty"` Status string `json:"status,omitempty"` }
SampleEntity sample data to save