handlers

package
v0.0.0-...-ff919dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseService

type DatabaseService interface {
	CreateQuote(ctx context.Context, quote *models.Quote) (string, error)
	GetAllQuotes(ctx context.Context, page int) ([]*models.Quote, error)
	GetQuote(ctx context.Context, objId primitive.ObjectID) (*models.Quote, error)
	SearchTags(ctx context.Context, tag string, page int) ([]*models.Quote, error)
	UpdateQuote(ctx context.Context, quote *models.Quote) (int64, error)
}

DatabaseService interface defines the database methods

type LoginHandler

type LoginHandler struct {
	AuthorisedUser *models.User
}

LoginHandler describes handler for access

func NewLoginHandler

func NewLoginHandler(authUser *models.User) *LoginHandler

NewAccessHandler returns an AccessHandler

func (*LoginHandler) Login

func (a *LoginHandler) Login(c *fiber.Ctx) error

Login method to create a new access token. @Description Login to create a new access token. @Summary Login to create a new access token @Tags login @Accept json @Produce json @Param user body models.User true "User" @Success 200 {string} status "ok" @Success 403 {string} status "forbidden" @Router /login [post]

type QuoteHandler

type QuoteHandler struct {
	Database DatabaseService
}

QuoteHandler describes handler for quotes

func NewQuoteHandler

func NewQuoteHandler(db DatabaseService) *QuoteHandler

NewQuoteHandler returns a QuoteHandler

func (*QuoteHandler) CreateQuote

func (q *QuoteHandler) CreateQuote(c *fiber.Ctx) error

CreateQuote func saves a quote into the database @Description Save a new quote into the database. @Summary Save a new quote @Tags quotes @Accept json @Produce json @Param quote body models.Quote true "Quote to be created, id and created_date should be deleted as values will be self-populated" @Success 200 {string} string @Failure 429 {string} string @Security ApiKeyAuth @Router /quote [post]

func (*QuoteHandler) GetAllQuotes

func (q *QuoteHandler) GetAllQuotes(c *fiber.Ctx) error

GetAllQuotes func gets all the quotes @Description Get all quotes (paginated in batches of 10, default start at page 1). @Summary Get all the quotes @Tags quotes @Accept json @Produce json @Param page path int true "Page of quotes" default(1) @Success 200 {array} models.Quote @Failure 429 {string} string @Router /quotes/{page} [get]

func (*QuoteHandler) GetQuote

func (q *QuoteHandler) GetQuote(c *fiber.Ctx) error

GetQuote func gets a quote @Description Get a quote by ID. @Summary Get a quote by ID @Tags quotes @Accept json @Produce json @Param id path string true "Quote ID" @Success 200 {object} models.Quote @Failure 429 {string} string @Security ApiKeyAuth @Router /quote/{id} [get]

func (*QuoteHandler) SearchTags

func (q *QuoteHandler) SearchTags(c *fiber.Ctx) error

SearchTags func gets a lits of quotes matching the given tag @Description Get quotes matching the tag (paginated in batches of 10, default start at page 1). @Summary Get quotes matching tag search @Tags quotes @Accept json @Produce json @Param tag path string true "Search tag" @Param page path int true "Page" default(1) @Success 200 {array} models.Quote @Failure 429 {string} string @Router /quotes/{tag}/{page} [get]

func (*QuoteHandler) UpdateQuote

func (q *QuoteHandler) UpdateQuote(c *fiber.Ctx) error

UpdateQuote func updates an existing a quote @Description Update a quote in the database. @Summary Update a quote @Tags quotes @Accept json @Produce json @Param id path string true "Quote ID" @Param quote body models.Quote true "Quote to be created, id and created_date should be deleted as values will be self-populated" @Success 200 {string} string @Failure 429 {string} string @Security ApiKeyAuth @Router /quote/{id} [post]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL