Documentation
¶
Overview ¶
Package standards centralizes interoperability constants and helpers used by tinySQL and applications built on top of it.
Index ¶
Constants ¶
View Source
const ( // MediaTypeJSON is the RFC 8259 JSON media type with an explicit UTF-8 charset. MediaTypeJSON = "application/json; charset=utf-8" // MediaTypeProblemJSON is the RFC 9457 Problem Details media type. MediaTypeProblemJSON = "application/problem+json" // MediaTypeCSV is the RFC 4180 CSV media type with an explicit UTF-8 charset. MediaTypeCSV = "text/csv; charset=utf-8" // MediaTypeTSV is the tab-separated-values media type with an explicit UTF-8 charset. MediaTypeTSV = "text/tab-separated-values; charset=utf-8" // MediaTypeXML is the XML 1.0 media type with an explicit UTF-8 charset. MediaTypeXML = "application/xml; charset=utf-8" // MediaTypeXLSX is the Office Open XML spreadsheet media type. MediaTypeXLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" // SQLStateSuccessfulCompletion is the ISO/IEC 9075 SQLSTATE success code. SQLStateSuccessfulCompletion = "00000" SQLStateWarning = "01000" SQLStateNoData = "02000" SQLStateDataException = "22000" SQLStateInvalidDatetime = "22007" SQLStateInvalidParameter = "22023" SQLStateSyntaxError = "42601" SQLStateUndefinedTable = "42P01" SQLStateIntegrityViolation = "23000" SQLStateInvalidAuthorization = "28000" SQLStateTransactionRollback = "40000" SQLStateInternalError = "XX000" )
Variables ¶
This section is empty.
Functions ¶
func FormatTime ¶
FormatTime formats timestamps for public APIs using RFC 3339 in UTC.
func WithSQLState ¶
WithSQLState wraps err with a SQLSTATE code. Nil errors stay nil.
func WriteProblem ¶
func WriteProblem(w http.ResponseWriter, problem Problem)
WriteProblem writes an RFC 9457 problem+json response.
Types ¶
type Problem ¶
type Problem struct {
Type string `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
Instance string `json:"instance,omitempty"`
Error string `json:"error,omitempty"`
}
Problem is an RFC 9457 Problem Details response. Error is a compatibility extension for older tinySQL/dbweb clients that read JSON responses via data.error.
func NewProblem ¶
NewProblem creates a Problem with a stable default type URI.
type SQLStateError ¶
SQLStateError attaches a SQLSTATE code to an underlying error.
func (*SQLStateError) Error ¶
func (e *SQLStateError) Error() string
func (*SQLStateError) Unwrap ¶
func (e *SQLStateError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.