Documentation
¶
Overview ¶
Package standards centralizes interoperability constants and helpers used by tinySQL and applications built on top of it.
Index ¶
Constants ¶
View Source
const ( // RFC 8259 JSON media type, sent with an explicit UTF-8 charset for HTTP. MediaTypeJSON = "application/json; charset=utf-8" // RFC 9457 Problem Details for HTTP APIs. MediaTypeProblemJSON = "application/problem+json" // RFC 4180 CSV and common tab-separated values media types. MediaTypeCSV = "text/csv; charset=utf-8" MediaTypeTSV = "text/tab-separated-values; charset=utf-8" // XML 1.0 and ECMA-376 / ISO/IEC 29500 spreadsheet exports. MediaTypeXML = "application/xml; charset=utf-8" MediaTypeXLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" // SQLSTATE class/code values from ISO/IEC 9075 and common vendor practice. 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.