Documentation ¶
Index ¶
- type ContextKey
- type Item
- type ItemInReceipt
- type ItemsDeleteBody
- type ItemsGetQuery
- type ItemsInReceiptDeleteBody
- type ItemsInReceiptPostBody
- type ItemsInReceiptPutBody
- type ItemsPostBody
- type ItemsPutBody
- type Location
- type LocationsDeleteBody
- type LocationsGetQuery
- type LocationsPostBody
- type LocationsPutBody
- type Options
- func (o Options) AuthCallbackHandler() gin.HandlerFunc
- func (o Options) AuthHandler() gin.HandlerFunc
- func (o Options) AuthRequired() gin.HandlerFunc
- func (o Options) CreateSessionID(ctx *gin.Context, user StructPublicID) error
- func (o Options) DeleteItems() gin.HandlerFunc
- func (o Options) DeleteItemsInReceipt() gin.HandlerFunc
- func (o Options) DeleteLocations() gin.HandlerFunc
- func (o Options) DeleteReceipts() gin.HandlerFunc
- func (o Options) GetItems() gin.HandlerFunc
- func (o Options) GetItemsInReceipt() gin.HandlerFunc
- func (o Options) GetLocations() gin.HandlerFunc
- func (o Options) GetReceipts() gin.HandlerFunc
- func (o Options) LogoutHandler() gin.HandlerFunc
- func (o Options) PostItems() gin.HandlerFunc
- func (o Options) PostItemsInReceipt() gin.HandlerFunc
- func (o Options) PostLocations() gin.HandlerFunc
- func (o Options) PostReceipts() gin.HandlerFunc
- func (o Options) PutItems() gin.HandlerFunc
- func (o Options) PutItemsInReceipt() gin.HandlerFunc
- func (o Options) PutLocations() gin.HandlerFunc
- func (o Options) PutReceipts() gin.HandlerFunc
- type Receipt
- type ReceiptWithData
- type ReceiptsDeleteBody
- type ReceiptsGetQuery
- type ReceiptsPostBody
- type ReceiptsPutBody
- type StructID
- type StructPublicID
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { PublicID string `db:"public_id" json:"id"` Name string `db:"name" json:"name"` Price float32 `db:"price" json:"price"` Unit string `db:"unit" json:"unit"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` }
Item : Structure that should be used for getting item information from database
type ItemInReceipt ¶
type ItemInReceipt struct { PublicID string `db:"public_id" json:"id"` ItemPublicID string `db:"item_public_id" json:"itemId"` Name string `db:"item_name" json:"name"` Price float32 `db:"item_price" json:"price"` Unit string `db:"item_unit" json:"unit"` Amount float32 `db:"amount" json:"amount"` }
ItemInReceipt : Structure that should be used for getting item information of a specific receipt from database
type ItemsDeleteBody ¶
type ItemsDeleteBody struct {
PublicID string `json:"id" validate:"required"`
}
ItemsDeleteBody : Structure that should be used for getting json data from body of a delete request for items
type ItemsGetQuery ¶
type ItemsGetQuery struct { // CreatedBy string `form:"createdBy"` Name string `form:"name"` }
ItemsGetQuery : Structure that should be used for getting query data on get request for items
type ItemsInReceiptDeleteBody ¶
type ItemsInReceiptDeleteBody struct { ItemID string `json:"itemId" validate:"required"` ReceiptID string `json:"receiptId"` }
ItemsInReceiptDeleteBody : Structure that should be used for getting json data from body of a delete request for items in a specific receipt
type ItemsInReceiptPostBody ¶
type ItemsInReceiptPostBody struct { ReceiptID string `json:"receiptId" validate:"required"` ItemID string `json:"itemId" validate:"required"` Amount float32 `json:"amount" validate:"required"` }
ItemsInReceiptPostBody : Structure that should be used for getting json from body of a post request for adding item to a receipt
type ItemsInReceiptPutBody ¶
type ItemsInReceiptPutBody struct { PublicID string `json:"id" validate:"required"` Amount float32 `json:"amount"` }
ItemsInReceiptPutBody : Structure that should be used for getting json from body of a put request for items form a specific receipt
type ItemsPostBody ¶
type ItemsPostBody struct { // CreatedBy string `json:"createdBy" validate:"required"` Name string `json:"name" validate:"required"` Price float32 `json:"price" validate:"required"` Unit string `json:"unit" validate:"required"` }
ItemsPostBody : Structure that should be used for getting json from body of a post request for items
type ItemsPutBody ¶
type ItemsPutBody struct { PublicID string `json:"id" validate:"required"` Name string `json:"name"` Price float32 `json:"price"` Unit string `json:"unit"` }
ItemsPutBody : Structure that should be used for getting json from body of a put request for items
type Location ¶
type Location struct { PublicID string `db:"public_id" json:"id"` Name string `db:"name" json:"name"` Address string `db:"address" json:"address"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` }
Location : Structure that should be used for getting location information from database
type LocationsDeleteBody ¶
type LocationsDeleteBody struct {
PublicID string `json:"id" validate:"required"`
}
LocationsDeleteBody : Structure that should be used for getting json data from body of a delete request for locations
type LocationsGetQuery ¶
type LocationsGetQuery struct {
Name string `form:"name"`
}
LocationsGetQuery : Structure that should be used for getting query data on get request for locations
type LocationsPostBody ¶
type LocationsPostBody struct { Name string `json:"name" validate:"required"` Address string `json:"address" validate:"required"` }
LocationsPostBody : Structure that should be used for getting json from body of a post request for locations
type LocationsPutBody ¶
type LocationsPutBody struct { PublicID string `json:"id" validate:"required"` Name string `json:"name"` Address string `json:"address"` }
LocationsPutBody : Structure that should be used for getting json from body of a put request for locations
type Options ¶
Options stores database and validator options for handlers
func (Options) AuthCallbackHandler ¶
func (o Options) AuthCallbackHandler() gin.HandlerFunc
AuthCallbackHandler is Google OAuth callback handler
func (Options) AuthHandler ¶
func (o Options) AuthHandler() gin.HandlerFunc
AuthHandler is Google OAuth handler
func (Options) AuthRequired ¶
func (o Options) AuthRequired() gin.HandlerFunc
AuthRequired verifies token sent via request in the cookie and checks if the user exists in the database. Afther that adds user id as a property inside request context.
func (Options) CreateSessionID ¶
func (o Options) CreateSessionID(ctx *gin.Context, user StructPublicID) error
CreateSessionID creates a session and returns the id for the user.
func (Options) DeleteItems ¶
func (o Options) DeleteItems() gin.HandlerFunc
DeleteItems is a Gin handler function for deleting items.
func (Options) DeleteItemsInReceipt ¶
func (o Options) DeleteItemsInReceipt() gin.HandlerFunc
DeleteItemsInReceipt is a Gin handler function for deleting items from a specific receipt.
func (Options) DeleteLocations ¶
func (o Options) DeleteLocations() gin.HandlerFunc
DeleteLocations is a Gin handler function for deleting a location.
func (Options) DeleteReceipts ¶
func (o Options) DeleteReceipts() gin.HandlerFunc
DeleteReceipts handlers delete requests for receipts
func (Options) GetItems ¶
func (o Options) GetItems() gin.HandlerFunc
GetItems is a Gin handler function for getting items.
func (Options) GetItemsInReceipt ¶
func (o Options) GetItemsInReceipt() gin.HandlerFunc
GetItemsInReceipt is a Gin handler function for getting items from a specific receipt.
func (Options) GetLocations ¶
func (o Options) GetLocations() gin.HandlerFunc
GetLocations is a Gin handler function for getting locations.
func (Options) GetReceipts ¶
func (o Options) GetReceipts() gin.HandlerFunc
GetReceipts handles get requests for receipts
func (Options) LogoutHandler ¶
func (o Options) LogoutHandler() gin.HandlerFunc
LogoutHandler is a handler for clearing login session storage
func (Options) PostItems ¶
func (o Options) PostItems() gin.HandlerFunc
PostItems is a Gin handler function for adding new items.
func (Options) PostItemsInReceipt ¶
func (o Options) PostItemsInReceipt() gin.HandlerFunc
PostItemsInReceipt is a Gin handler function for adding new items to a specific receipt.
func (Options) PostLocations ¶
func (o Options) PostLocations() gin.HandlerFunc
PostLocations is a Gin handler function for adding new locations.
func (Options) PostReceipts ¶
func (o Options) PostReceipts() gin.HandlerFunc
PostReceipts handles post requests for receipts
func (Options) PutItems ¶
func (o Options) PutItems() gin.HandlerFunc
PutItems is a Gin handler function for updating items.
func (Options) PutItemsInReceipt ¶
func (o Options) PutItemsInReceipt() gin.HandlerFunc
PutItemsInReceipt is a Gin handler function for updating items in a specific receipt.
func (Options) PutLocations ¶
func (o Options) PutLocations() gin.HandlerFunc
PutLocations is a Gin handler function for updating a location.
func (Options) PutReceipts ¶
func (o Options) PutReceipts() gin.HandlerFunc
PutReceipts handles put requests for receipts
type Receipt ¶
type Receipt struct { PublicID string `db:"public_id" json:"id"` LocationID string `db:"location_id" json:"locationId"` CreatedBy string `db:"created_by" json:"createdBy"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` }
Receipt : Structure that should be used for getting receipt information from database
type ReceiptWithData ¶
type ReceiptWithData struct { PublicID string `json:"id" graphql:"id"` CreatedBy string `json:"createdBy" graphql:"createdBy"` Location Location `json:"location" graphql:"location"` TotalPrice float64 `json:"totalPrice" graphql:"totalPrice"` CreatedAt time.Time `json:"createdAt" grpahql:"createdAt"` UpdatedAt time.Time `json:"updatedAt" graphql:"updatedAt"` }
ReceiptWithData : Structure that should be used for getting receipt information including names, addresses, and everything else from receipts location from database
type ReceiptsDeleteBody ¶
type ReceiptsDeleteBody struct {
PublicID string `json:"id" validate:"required"`
}
ReceiptsDeleteBody : Structure that should be used for getting json data from body of a delete request for items
type ReceiptsGetQuery ¶
ReceiptsGetQuery : Structure that should be used for getting query data on get request for receipts
type ReceiptsPostBody ¶
type ReceiptsPostBody struct { LocationPublicID string `json:"id" validate:"required"` CreatedAt string `json:"createdAt"` }
ReceiptsPostBody : Structure that should be used for getting json from body of a post request for receipts
type ReceiptsPutBody ¶
type ReceiptsPutBody struct { PublicID string `json:"id" validate:"required"` LocationID string `json:"locationId"` }
ReceiptsPutBody : Structure that should be used for getting json from body of a put request for receipts
type StructPublicID ¶
type StructPublicID struct {
PublicID string `db:"public_id"`
}
StructPublicID is a struct for storing only public id
func GetUserID ¶
func GetUserID(ctx *gin.Context) (StructPublicID, bool)
GetUserID get the user id from specified context. It's literally used just so I can write one line instead of two.