Documentation ¶
Index ¶
- Variables
- 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 JsonapiSearchResultRaw(result string) (string, error)
- func LogEvent(thelog StructuredLog, level, event, msg string)
- func LogNew(level, event, msg string)
- func MountRoute(router *gin.RouterGroup)
- type ItemDataGen
- type JsonapiDataGen
- type JsonapiError
- type JsonapiErrorItem
- type StructuredLog
Constants ¶
This section is empty.
Variables ¶
var ServiceName = "SearchAPI"
ServiceName name of service
var SourceName = "SearchAPI"
SourceName for error response
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 JsonapiSearchResultRaw ¶
JsonapiSearchResultRaw es to jsonapi.org format Elasticsearch already responding with json, and we have so far no much changes in that. so don't want to decode and encode json to give jsonapi.org format. here the solution is done without unmarshaling, using gjson and sjson
func LogEvent ¶
func LogEvent(thelog StructuredLog, level, event, msg string)
LogEvent in json format
func LogNew ¶
func LogNew(level, event, msg string)
LogNew is to log with a new StructuredLog struct
func MountRoute ¶
func MountRoute(router *gin.RouterGroup)
MountRoute func will mount all rest routes
Types ¶
type ItemDataGen ¶
type ItemDataGen struct { Type string `json:"type"` ID string `json:"id"` Attributes interface{} `json:"attributes"` }
ItemDataGen General
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 StructuredLog ¶
type StructuredLog 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"` Account string `json:"account,omitempty"` ID string `json:"id,omitempty"` Raw string `json:"raw,omitempty"` RawInterface interface{} `json:"rawInterface,omitempty"` }
StructuredLog struct for structured loggin