Documentation ¶
Index ¶
- Constants
- func ContextWithDb(ctx context.Context, db *bun.DB) context.Context
- func ContextWithTx(ctx context.Context, tx *bun.Tx) context.Context
- func ContextWithValue(ctx context.Context, keyName string, value interface{}) context.Context
- func DbFromContext(ctx context.Context) *bun.DB
- func Execute(ctx context.Context, execFunc ExecFunc) error
- func ExecuteWithPropagation(ctx context.Context, propagation Propagation, execFunc ExecFunc) error
- func TxFromContext(ctx context.Context) *bun.Tx
- func ValueFromContext(ctx context.Context, keyName string) interface{}
- func Version() string
- type Action
- type AfterHook
- type BeforeHook
- type Config
- func (c *Config) AddResource(resource *Resource)
- func (c *Config) DB() *bun.DB
- func (c *Config) DefaultAccept() string
- func (c *Config) DefaultContentType() string
- func (c *Config) ErrorLogger() *log.Logger
- func (c *Config) GetResource(resourceName string) *Resource
- func (c *Config) InfoLogger() *log.Logger
- func (c *Config) Prefix() string
- func (c *Config) SetDefaultAccept(defaultAccept string)
- func (c *Config) SetDefaultContentType(defaultContentType string)
- func (c *Config) SetErrorLogger(logger *log.Logger)
- func (c *Config) SetInfoLogger(logger *log.Logger)
- func (c *Config) SetPrefix(prefix string)
- func (c *Config) String() string
- type Engine
- type Error
- type ExecFunc
- type Executor
- type Field
- type Filter
- type Op
- type Page
- type Propagation
- type Relation
- type Resource
- type RestQuery
- type Server
- type Sort
Constants ¶
const ( // Form content type Form string = "application/x-www-form-urlencoded" // Json content type Json = "application/json" // Msgpack content type Msgpack = "application/x-msgpack" )
Variables ¶
This section is empty.
Functions ¶
func ContextWithDb ¶
ContextWithDb sets Db to context request
func ContextWithTx ¶
ContextWithTx sets Tx to context request
func ContextWithValue ¶
ContextWithValue sets Value to context request
func DbFromContext ¶
DbFromContext retrives Db from context
func ExecuteWithPropagation ¶
func ExecuteWithPropagation(ctx context.Context, propagation Propagation, execFunc ExecFunc) error
ExecuteWithPropagation executes ExecFunc in transaction with specific propagation
func TxFromContext ¶
TxFromContext retrives Tx from context
func ValueFromContext ¶
ValueFromContext retrives Value from context
Types ¶
type BeforeHook ¶ added in v1.0.2
BeforeHook defines before execution callback function
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config structure
func (*Config) AddResource ¶
AddResource adds resource
func (*Config) DefaultAccept ¶
DefaultAccept gets defaultAccept
func (*Config) DefaultContentType ¶
DefaultContentType gets defaultContentType
func (*Config) ErrorLogger ¶
ErrorLogger gets error logger
func (*Config) GetResource ¶
GetResource gets resource
func (*Config) SetDefaultAccept ¶
SetDefaultAccept sets defaultAccept
func (*Config) SetDefaultContentType ¶
SetDefaultContentType sets defaultContentType
func (*Config) SetErrorLogger ¶
SetErrorLogger sets error logger
func (*Config) SetInfoLogger ¶
SetInfoLogger sets info logger
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine structure
func (*Engine) Deserialize ¶
Deserialize deserializes data into entity
type Error ¶
Error struct
func NewErrorBadRequest ¶
NewErrorBadRequest constructs Error with bad request code
func NewErrorForbbiden ¶
NewErrorForbbiden constructs Error with forbidden code
func NewErrorFromCause ¶
NewErrorFromCause constructs Error from cause error
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor structure
func NewExecutor ¶
NewExecutor constructs Executor
func (*Executor) DeleteExecFunc ¶
DeleteExecFunc deletes execution function
func (*Executor) GetOneExecFunc ¶
GetOneExecFunc gets one execution function
func (*Executor) GetSliceExecFunc ¶
GetSliceExecFunc gets slice execution function
func (*Executor) InsertExecFunc ¶
InsertExecFunc inserts execution function
func (*Executor) UpdateExecFunc ¶
UpdateExecFunc updates execution function
type Filter ¶
type Filter struct { Op Op // operation Attr string // attribute name Value interface{} // attribute value Filters []*Filter // sub filters for 'and' and 'or' operations }
Filter structure
type Op ¶
type Op string
Op operation filter type
const ( // And operation for group And Op = "and" // Or operation for group Or Op = "or" // Eq operation for attribute (? = ?) Eq Op = "eq" // Neq operation for attribute (? != ?) Neq Op = "neq" // In operation for attribute (? IN ?) In Op = "in" // Nin operation for attribute (? NOT IN ?) Nin Op = "nin" // Gt operation for attribute (? > ?) Gt Op = "gt" // Gte operation for attribute (? >= ?) Gte Op = "gte" // Lt operation for attribute (? < ?) Lt Op = "lt" // Lte operation for attribute (? <= ?) Lte Op = "lte" // Lk operation for attribute (? LIKE ?) Lk Op = "lk" // Nlk operation for attribute (? NOT LIKE ?) Nlk Op = "nlk" // Ilk operation for attribute (? LOWER LIKE ?) Llk Op = "ilk" // Nilk operation for attribute (? NOT LOWER LIKE ?) Nllk Op = "nilk" // Sim operation for attribute (? SIMILAR TO ?) Sim Op = "sim" // Nsim operation for attribute (? NOT SIMILAR TO ?) Nsim Op = "nsim" // Lulk operation for attribute (? LOWER UNACCENT LIKE ?) Lulk Op = "ilkua" // Nlulk operation for attribute (? NOT LOWER UNACCENT ILIKE ?) Nlulk Op = "nilkua" // Null operation for attribute (? IS NULL) Null Op = "null" // Nnull operation for attribute (? IS NOT NULL) Nnull Op = "nnull" )
type Page ¶
type Page struct { Slice interface{} `json:"slice"` Offset int `json:"offset"` Limit int `json:"limit"` Count int `json:"count"` }
Page structure
type Propagation ¶
type Propagation string
Propagation type
const ( // Current supports a current transaction, creates a new one if none exists. Current Propagation = "Current" // Mandatory needs a current transaction, return an exception if none exists Mandatory Propagation = "Mandatory" // Savepoint supports a current transaction, creates a new one if none exists, creates savepoint and never return propagation error Savepoint Propagation = "Savepoint" )
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource structure
func NewResource ¶
NewResource constructs Resource
func NewResourceWithHooks ¶ added in v1.0.2
func NewResourceWithHooks(name string, entity interface{}, action Action, beforeHook BeforeHook, afterHook AfterHook) *Resource
NewResourceWithHooks constructs Resource with hooks
func (*Resource) ResourceType ¶
ResourceType returns resourceType
type RestQuery ¶
type RestQuery struct { Request *http.Request Action Action Resource string Key string ContentType string Accept string Content interface{} Offset int Limit int Fields []*Field Relations []*Relation Sorts []*Sort Filter *Filter Debug bool }
RestQuery structure
func RequestDecoder ¶
RequestDecoder decodes rest parameters from request
type Server ¶
type Server struct { Engine // contains filtered or unexported fields }
Server structure
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(writer http.ResponseWriter, request *http.Request)
ServeHTTP serves rest request
func (*Server) SetNextHandler ¶
SetNextHandler sets next handler for middleware use