Documentation
¶
Index ¶
- type ErrorResponse
- type GinRouter
- type LoginInput
- type LoginResponse
- type MessageResponse
- type Router
- func (r Router) AddFact(context *gin.Context)
- func (r Router) DeleteFact(context *gin.Context)
- func (r Router) GetFactById(context *gin.Context)
- func (r Router) GetHealth(context *gin.Context)
- func (r Router) GetRandomFact(context *gin.Context)
- func (r Router) Login(context *gin.Context)
- func (r Router) StartRouter(port string)
- func (r Router) UpdateFact(context *gin.Context)
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 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 ¶
@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 ¶
@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 ¶
@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 ¶
@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 ¶
@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 ¶
@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 (Router) UpdateFact ¶
@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]