Documentation
¶
Overview ¶
Package rest provide the implementation of http query parser
Index ¶
- Variables
- func Delete[Model any](route string, httpClient http.Client) (Model, error)
- func Get[Model any](route string, httpClient http.Client) (Model, error)
- func Post[Input any, Model any](route string, httpClient http.Client, input Input) (Model, error)
- func Put[Input any, Model any](route string, httpClient http.Client, input Input) (Model, error)
- type Error
- type Filter
- func (f *Filter) AddOrderBy(field string, order string) *Filter
- func (f *Filter) FromRouteParams(v url.Values) *Filter
- func (f *Filter) Load(names ...string) *Filter
- func (f *Filter) OrWhere(name string, compareWith string, compareTo string) *Filter
- func (f *Filter) SetItemPerPage(itemPerPage int) *Filter
- func (f *Filter) SetPage(page int) *Filter
- func (f *Filter) SetWith(w []string) *Filter
- func (f *Filter) SetWithTrashed(withTrashed bool) *Filter
- func (f *Filter) String() string
- func (f *Filter) Where(name string, compareWith string, compareTo string) *Filter
- type Pager
- type Response
- type ValidationErrorResponse
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultItemPerPage = 25
View Source
var DefaultWithTrashed = false
Functions ¶
Types ¶
type Error ¶ added in v0.0.5
type Error struct { Status string `json:"status" example:"Error Status"` Message string `json:"message" example:"Error message example"` // contains filtered or unexported fields }
func ErrorWithMessage ¶ added in v0.0.5
type Filter ¶
type Filter struct { Wheres []where.Input `json:"wheres"` OrWheres []where.Input `json:"or_wheres"` OrderBy orderBy.Input `json:"order_by"` With with.Input `json:"with"` Page int `json:"page"` ItemPerPage int `json:"item_per_page"` WithTrashed bool `json:"with_trashed"` }
func (*Filter) AddOrderBy ¶
AddOrderBy define order by clause, map of field and order direction as value ("asc" or "desc")
func (*Filter) SetItemPerPage ¶
func (*Filter) SetWithTrashed ¶
type Pager ¶
type Pager struct { CurrentPage int `json:"current_page"` From int `json:"from"` To int `json:"to"` Total int `json:"total"` LastPage int `json:"last_page"` PerPage int `json:"per_page"` FirstPageUrl string `json:"first_page_url"` LastPageUrl string `json:"last_page_url"` NextPageUrl string `json:"next_page_url"` PrevPageUrl string `json:"prev_page_url"` }
type Response ¶
type Response[Data any] struct { Status string `json:"status"` Data Data `json:"data"` Message string `json:"message"` Pager Pager `json:"pager"` }
type ValidationErrorResponse ¶
Click to show internal directories.
Click to hide internal directories.