Documentation
¶
Index ¶
Constants ¶
const ( OptionFilter = "$filter" OptionOrderBy = "$orderby" OptionTop = "$top" OptionSkip = "$skip" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type Author ¶
type Author struct { ID string `json:"id" regex:"(?i)^[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}$"` FirstName string `json:"first_name" regex:"^[\p{L}&\s-\\'’.]{2,256}$"` LastName string `json:"last_name" regex:"^[\p{L}&\s-\\'’.]{2,256}$"` CreatedAt time.Time `json:"created_at"` }
type Book ¶
type Book struct { ID string `json:"id" sql:"id"` AuthorID string `json:"author_id" sql:"author_id" regex:"(?i)^[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}$"` Title string `json:"title" sql:"title" regex:"^[[:graph:]]{1,256}$"` // TODO: Add ISBN Genre string `json:"genre" sql:"genre" regex:"^[[:graph:]]{1,256}$"` Rate int `json:"rate" sql:"rate" regex:"^([[:digit:]]|10)$"` Size int `json:"size" sql:"size" regex:"^[[:digit:]]{1,256}$"` Year int `json:"year" sql:"year" regex:"^[[:digit:]]{4}$"` }
type Credentials ¶
type Credentials struct { Email string `json:"email" regex:"(?i)(^[a-z0-9_.+-]+@[a-z0-9-]+\.[a-z0-9-.]+$)"` Password string `json:"password" regex:"^[[:graph:]]{8,256}$"` }
func (*Credentials) Normalize ¶
func (c *Credentials) Normalize()
func (*Credentials) OK ¶
func (c *Credentials) OK() error
type DataFilter ¶
DataFilter represents a set of [OData](https://www.odata.org/getting-started/basic-tutorial/#queryData) query options to filter and sort data. It supports the following query options:
- $filter: optional parameter that represents a filter operation with operations: 'and', 'or', 'eq', 'ne', 'gt', 'lt', 'ge', 'le'.
- $orderby: optional parameter that represents a sorting column with operators: 'asc' and 'desc'.
- $top: optional parameter that represents a limit of items from the resource.
- $skip: optional parameter that represents an offset of records in the resource.
The names of fields must correspond to struct field names and should be provided in case-sensitive format.
Example: http://localhost:8080/books?$filter=Author eq 'Papa Karlo' and Title eq 'Pinocchio'&$orderby=Title desc&$skip=1&$top=10
TODO: add following properties: `from`, `to` (in UTC format), `in` Sequences (ids of sequences).
func NewDataFilter ¶
func NewDataFilter[T any](u *url.URL) (*DataFilter, error)
NewDataFilter creates a new instance of *DataFilter of struct type T based on the OData query options present in the specified URL. The input of the OData query options will be validated during the process.
func (*DataFilter) UpdateURL ¶
func (df *DataFilter) UpdateURL()
UpdateURL makes query on top of parent URL.
type Filter ¶
type Filter struct { RawQuery string Head *FilterNode }
Filter represent linked lists of OData expressions.
type FilterNode ¶
type FilterNode struct { Field string Operator string Conjunction string Value string Next *FilterNode }
FilterNode represents OData expression.
type Logger ¶
type Logger interface { Flush() error Level() string With(...any) Debugf(string, ...any) Debugw(string, ...any) Infof(string, ...any) Infow(string, ...any) Warnf(string, ...any) Warnw(string, ...any) Errorf(string, ...any) Errorw(string, ...any) // Fatal ... are essential for migrations. Fatal(...any) Fatalf(string, ...any) Print(...any) Println(...any) Printf(string, ...any) }
Logger is designed for logging.
type Reader ¶
type Reader struct { ID string `json:"id"` // regex:"(?i)^[0-9a-f]{8}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{4}\b-[0-9a-f]{12}$" FirstName string `json:"first_name" regex:"^[\p{L}&\s-\\'’.]{2,256}$"` LastName string `json:"last_name" regex:"^[\p{L}&\s-\\'’.]{2,256}$"` Email string `json:"email" regex:"(?i)(^[a-z0-9_.+-]+@[a-z0-9-]+\.[a-z0-9-.]+$)"` Password string `json:"password" regex:"^[[:graph:]]{8,256}$"` Role string `json:"role"` CreatedAt time.Time `json:"created_at"` DeletedAt time.Time `json:"deleted_at"` }