Documentation
¶
Index ¶
- Variables
- type APIContext
- type Chain
- type ColumnDataType
- type ContextKey
- type DatabaseType
- type Error
- type ErrorCode
- type GlobalThisReader
- type Handler
- type HandlerFunc
- type MutableRequestContext
- type MutableResponseContext
- type PersistenceContext
- type PreparedQuery
- type QueryResult
- type QueryType
- type Repository
- type RequestContext
- type ResponseContext
- type ScriptRunner
- type TableType
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ApiCtxKey = ContextKey{}
Functions ¶
This section is empty.
Types ¶
type APIContext ¶ added in v0.1.0
type APIContext interface {
RequestContext
ResponseContext
MutableRequestContext
MutableResponseContext
}
APIContext combines request and response contexts
type ColumnDataType ¶
type ColumnDataType string
type ContextKey ¶ added in v0.1.1
type ContextKey struct{}
type DatabaseType ¶
type DatabaseType string
type Error ¶ added in v0.1.4
func NewError ¶ added in v0.1.4
Example ¶
err := NewError("E001", "An error occurred", "data")
fmt.Println(err)
fmt.Println(err.Code())
fmt.Println(err.Data())
err = NewError("E005", "An error occurred", underlyingError)
fmt.Println(err)
Output: An error occurred E001 data An error occurred, cause: underlying error
type GlobalThisReader ¶
type Handler ¶ added in v0.1.3
type Handler interface {
Handle(APIContext)
}
type HandlerFunc ¶ added in v0.1.3
type HandlerFunc func(APIContext)
func (HandlerFunc) Handle ¶ added in v0.1.3
func (h HandlerFunc) Handle(ctx APIContext)
type MutableRequestContext ¶ added in v0.1.0
type MutableRequestContext interface {
SetRequestID(string)
SetMethod(string)
SetParams(any)
SetRawParams([]byte)
SetMetas(map[string]any)
}
MutableRequestContext allows modification of request context
type MutableResponseContext ¶ added in v0.1.0
MutableResponseContext allows modification of response context
type PersistenceContext ¶
type PreparedQuery ¶
type PreparedQuery struct {
Query string `json:"query"`
Bind []any `json:"bind"`
QueryType QueryType `json:"queryType"`
CheckPoint []*PreparedQuery `json:"checkPoint"`
DatabaseUpdater []*PreparedQuery `json:"databaseUpdater"`
ResultEnricher []*PreparedQuery `json:"resultEnricher"`
}
type QueryResult ¶
type Repository ¶
type Repository interface {
BindNamed(query string, arg any) (string, []any, error)
Find(query string, args ...any) (map[string]any, error)
FindAll(query string, args ...any) ([]map[string]any, error)
Insert(query string, args ...any) (int64, error)
InsertBatch(query string, args ...any) (int64, error)
// InsertNamedBatch
// Deprecated
InsertNamedBatch(query string, args []any) (int64, error)
Update(query string, args ...any) (int64, error)
Delete(query string, args ...any) (int64, error)
Begin() error
Commit() error
Rollback() error
Exec(query string, args ...any) error
DriverName() string
QueryTotal() int64
SetTraceId(traceId string)
}
type RequestContext ¶ added in v0.1.0
type RequestContext interface {
RequestID() string
Method() string
Params() any
RawParams() []byte
Metas() map[string]any
}
RequestContext contains request-related information
type ResponseContext ¶ added in v0.1.0
ResponseContext contains response-related information
type ScriptRunner ¶
Click to show internal directories.
Click to hide internal directories.