Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Status int `json:"status,omitempty"`
Source map[string]string `json:"source,omitempty"`
Title string `json:"title,omitempty"`
Detail string `json:"detail,omitempty"`
}
func NewError ¶
NewErrors constructs a slice of Error objects from the provided slices. Each Error object is populated with the corresponding elements from the input slices.
Parameters:
- titles: a slice of error titles (required).
- details: a slice of error details (optional).
- sources: a slice of slices, where each inner slice contains key-value pairs for the Source map in an Error object (optional).
- statuses: a slice of status codes (optional).
The function handles cases where the optional slices have fewer elements than the titles slice. If an optional slice is shorter, the missing values are omitted for those Error objects.
Example usage:
titles := []string{"Error 1", "Error 2"}
details := []string{"Detail 1", "Detail 2"}
sources := [][]string{
{"file", "main.go", "line", "42"},
{"file", "utils.go"},
}
statuses := []int{400, 404}
errors := NewErrors(titles, details, sources, statuses)
// The errors slice will contain:
errors[0] = Error{
Title: "Error 1",
Detail: "Detail 1",
Status: 400,
Source: map[string]string{
"file": "main.go",
"line": "42",
},
}
errors[1] = Error{
Title: "Error 2",
Detail: "Detail 2",
Status: 404,
Source: map[string]string{
"file": "utils.go",
},
}
type JSONAPI ¶
type Link ¶
type Meta ¶
type Meta struct {
Message string `json:"message,omitempty"`
NodeID string `json:"node_id,omitempty"`
ProfileURL string `json:"profile_url,omitempty"`
NumberOfResults int64 `json:"number_of_results,omitempty"`
TotalPages int64 `json:"total_pages,omitempty"`
Sort []interface{} `json:"sort,omitempty"`
BatchID string `json:"batch_id,omitempty"`
}
func NewBatchMeta ¶
func NewBlockSearchMeta ¶
func NewBlockSearchMeta(sort []interface{}) *Meta
Click to show internal directories.
Click to hide internal directories.