Documentation
¶
Index ¶
- type ClientSchema
- type CreationSchema
- type Quote
- func (q *Quote) Create(ctx *gin.Context)
- func (q *Quote) Delete(ctx *gin.Context)
- func (q *Quote) GetAll(ctx *gin.Context)
- func (q *Quote) GetRandom(ctx *gin.Context)
- func (q *Quote) GetSingle(ctx *gin.Context)
- func (q *Quote) ReturnOne(filter map[string]interface{}) (ResponseSchema, error)
- func (q *Quote) Routes() []types.RouteDetails
- func (q *Quote) Update(ctx *gin.Context)
- type ResponseSchema
- type UpdateSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientSchema ¶
type ClientSchema struct {
Quote string `json:"quote"`
}
ClientSchema is the schema the data from the client will be marshalled into
type CreationSchema ¶
type CreationSchema struct {
ClientSchema
// Ignore these fields in user input, they will be filled automatically by the API
CreatedAt time.Time `json:"createdAt"`
DeletedAt float64 `json:"deletedAt"`
Token string `json:"token"`
QuoteID int `json:"quoteId"`
Enabled bool `json:"enabled"`
}
CreationSchema is all the data required for a new quote to be created
func (CreationSchema) DumpBody ¶
func (cs CreationSchema) DumpBody(data []byte) ([]byte, error)
DumpBody dumps the body data bytes into this specific schema and returns the bytes from this
func (CreationSchema) GetAPITag ¶
func (cs CreationSchema) GetAPITag(lookup string) string
GetAPITag allows each of these types to implement the JSONAPISchema interface
type Quote ¶
type Quote struct {
Conn *rethink.Connection // The RethinkDB connection
Table string // The database table we're using
}
Quote is the struct that implements the handler interface for the quote resource
func (*Quote) ReturnOne ¶
func (q *Quote) ReturnOne(filter map[string]interface{}) (ResponseSchema, error)
ReturnOne retrieves a single record given the filter provided
func (*Quote) Routes ¶
func (q *Quote) Routes() []types.RouteDetails
Routes returns the routing information for this endpoint
type ResponseSchema ¶
type ResponseSchema struct {
ID string `jsonapi:"primary,quote"`
CreatedAt string `jsonapi:"meta,createdAt"`
Enabled bool `jsonapi:"attr,enabled"`
QuoteID int `jsonapi:"attr,quoteId"`
Quote string `jsonapi:"attr,quote"`
Token string `jsonapi:"meta,token"`
}
ResponseSchema is the schema for the data that will be sent out to the client
func (ResponseSchema) DumpBody ¶
func (rs ResponseSchema) DumpBody(data []byte) ([]byte, error)
DumpBody dumps the body data bytes into this specific schema and returns the bytes from this
func (ResponseSchema) GetAPITag ¶
func (rs ResponseSchema) GetAPITag(lookup string) string
GetAPITag allows each of these types to implement the JSONAPISchema interface
func (ResponseSchema) JSONAPIMeta ¶
func (rs ResponseSchema) JSONAPIMeta() *types.Meta
JSONAPIMeta returns a meta object for the response
type UpdateSchema ¶
type UpdateSchema struct {
Quote string `json:"quote,omitempty"`
Enabled bool `json:"enabled,omitempty"`
}
UpdateSchema is ClientSchema that is used when updating
func (UpdateSchema) DumpBody ¶
func (us UpdateSchema) DumpBody(data []byte) ([]byte, error)
DumpBody dumps the body data bytes into this specific schema and returns the bytes from this
func (UpdateSchema) GetAPITag ¶
func (us UpdateSchema) GetAPITag(lookup string) string
GetAPITag allows each of these types to implement the JSONAPISchema interface