router

package
v0.0.0-...-f3b85f2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error error
}

type GinRouter

type GinRouter interface {
	AddFact(context *gin.Context)
	DeleteFact(context *gin.Context)
	GetHealth(context *gin.Context)
	GetRandomFact(context *gin.Context)
	GetFactById(context *gin.Context)
	UpdateFact(context *gin.Context)
	StartRouter(port string)
}

func NewRouter

func NewRouter(authHandler auth.AuthHandler, factHandler facts.FactHandler) GinRouter

type LoginInput

type LoginInput struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

type MessageResponse

type MessageResponse struct {
	Message string
}

type Router

type Router struct {
	Router      *gin.Engine
	AuthHandler auth.AuthHandler
	FactHandler facts.FactHandler
}

func (Router) AddFact

func (r Router) AddFact(context *gin.Context)

@Summary Add a new animal fact @Schemes https @Description Adding an animal fact @Tags facts @Accept json @Param request body database.Fact true "a new fact" @Produce json @Success 201 {object} database.Fact @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /fact [post]

func (Router) DeleteFact

func (r Router) DeleteFact(context *gin.Context)

@Summary Delete an animal fact @Schemes https @Description Deleting an animal fact @Tags facts @Produce json @Success 200 {object} MessageResponse @Failure 500 {object} ErrorResponse @Router /fact/:id [delete]

func (Router) GetFactById

func (r Router) GetFactById(context *gin.Context)

@Summary Get animal fact by id @Schemes https @Description Getting an animal fact by id @Tags facts @Produce json @Success 200 {object} database.Fact @Failure 404 {object} ErrorResponse @Router /fact/:id [get]

func (Router) GetHealth

func (r Router) GetHealth(context *gin.Context)

@Summary Get health status @Schemes https @Description Checking the health of the API @Tags general @Produce plain @Success 200 {string} healthy @Router /healthy [get]

func (Router) GetRandomFact

func (r Router) GetRandomFact(context *gin.Context)

@Summary Get random animal fact @Schemes https @Description Getting a random animal fact @Tags facts @Produce json @Success 200 {object} database.Fact @Failure 500 {object} ErrorResponse @Router /fact [get]

func (Router) Login

func (r Router) Login(context *gin.Context)

@Summary Login endpoint @Schemes https @Description Login endpoint for the endpoints of the API, that require auth @Tags general @Produce json @Success 200 {object} LoginResponse @Router /login [post]

func (Router) StartRouter

func (r Router) StartRouter(port string)

func (Router) UpdateFact

func (r Router) UpdateFact(context *gin.Context)

@Summary Update an existing animal fact @Schemes https @Description Updating an animal fact @Tags facts @Accept json @Param request body interface{} true "an updated fact" @Produce json @Success 200 {object} database.Fact @Failure 400 {object} ErrorResponse @Failure 404 {object} MessageResponse @Failure 500 {object} ErrorResponse @Router /fact/:id [put]

Jump to

Keyboard shortcuts

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