Documentation ¶
Index ¶
- Constants
- Variables
- func Count(cfg Config, req Request) (query string, args map[string]interface{}, err error)
- func Field(name string) field
- func Prepare(cfg Config, req Request) (query string, args map[string]interface{}, err error)
- func PrepareCount(cfg Config, req Request, searchTarget string) (query string, args map[string]interface{}, err error)
- type Config
- type Fields
- type M
- type OrderType
- type Params
- type Request
- type Response
- func BadRequest(msg string, info ...interface{}) Response
- func BadRequestWithReason(msg string, reason string, info ...interface{}) Response
- func Forbidden(info ...interface{}) Response
- func ForbiddenWithReason(reason string, info ...interface{}) Response
- func InvalidForm(err error, info ...interface{}) Response
- func InvalidJSON(err error, info ...interface{}) Response
- func NotFound(info ...interface{}) Response
- func NotFoundWithReason(reason string, info ...interface{}) Response
- func ServerError(err error, info ...interface{}) Response
- func ServerErrorWithReason(err error, reason string, info ...interface{}) Response
- func Stack(err error, info ...interface{}) Response
- func Stackf(err error, info ...interface{}) Response
- func Unauthorized(info ...interface{}) Response
- func UnauthorizedWithReason(reason string, info ...interface{}) Response
Constants ¶
View Source
const (
LimitDefault = 50
)
Variables ¶
View Source
var ( Development bool MsgServerError = "server-error" MsgForbidden = "access-denied" MsgNotFound = "not-found" )
View Source
var ( ErrNoFields = errors.New("No fields selected") ErrFilterStructure = errors.New("the filter string does not match the allowed structure") ErrFilterNotAllowed = errors.New("the filter is not allowed") ErrOrderInvalidStructure = errors.New("The order string does not match the allowed structure") ErrOrderNotAllowed = errors.New("The order is not allowed") )
Functions ¶
Types ¶
type Config ¶
type Config struct { Fields Fields Distinct bool Table string Where string GroupBy string CalcRows bool AdditionalParams Params }
The query builder configuration structure.
type Params ¶
type Params map[string]interface{}
Additional params that will be injected into the overall query building proces.
type Request ¶
type Request struct { Fields string `json:"fields" form:"fields" query:"fields"` Filter string `json:"filter" form:"filter" query:"filter"` Order string `json:"order" form:"order" query:"order"` Limit uint `json:"limit" form:"limit" query:"limit"` Offset uint `json:"offset" form:"offset" query:"offset"` Search string `json:"search" form:"search" query:"search"` }
Structure that can be used in conjunction with request handling to simplify the config collection process.
type Response ¶
type Response interface { error // GetCode returns the code of this response GetCode() int // SetCode sets the response code SetCode(int) // GetTracking returns the tracking id GetTracking() string // GetReason set the reason for this GetReason() string // GetMessage returns the core message of this response GetMessage() string // SetMessage sets the core message SetMessage(string) // GetStack returns the custom error stack GetStack() []string // GetSource returns the original error GetSource() error // contains filtered or unexported methods }
Response
func BadRequest ¶
func BadRequestWithReason ¶
func ForbiddenWithReason ¶
func InvalidForm ¶
func InvalidJSON ¶
func NotFoundWithReason ¶
func ServerError ¶
func ServerErrorWithReason ¶
func Unauthorized ¶
func Unauthorized(info ...interface{}) Response
func UnauthorizedWithReason ¶
Click to show internal directories.
Click to hide internal directories.