jokes-bapak2/api/app/v1/routes/joke.go

34 lines
737 B
Go
Raw Normal View History

2021-07-09 06:11:11 +00:00
package routes
import (
"jokes-bapak2-api/app/v1/handler/joke"
2021-07-14 18:17:01 +00:00
"jokes-bapak2-api/app/v1/middleware"
2021-07-09 06:11:11 +00:00
"github.com/gofiber/fiber/v2"
)
2021-07-09 12:13:19 +00:00
func Joke(app *fiber.App) *fiber.App {
2021-07-09 06:11:11 +00:00
// Single route
app.Get("/", joke.SingleJoke)
2021-07-09 06:11:11 +00:00
// Today's joke
app.Get("/today", joke.TodayJoke)
2021-07-09 06:11:11 +00:00
// Joke by ID
app.Get("/id/:id", middleware.OnlyIntegerAsID(), joke.JokeByID)
2021-07-17 14:37:01 +00:00
// Count total jokes
app.Get("/total", joke.TotalJokes)
2021-07-09 06:11:11 +00:00
// Add new joke
app.Put("/", middleware.RequireAuth(), joke.AddNewJoke)
2021-07-09 06:11:11 +00:00
// Update a joke
app.Patch("/id/:id", middleware.RequireAuth(), middleware.OnlyIntegerAsID(), joke.UpdateJoke)
2021-07-09 06:11:11 +00:00
// Delete a joke
app.Delete("/id/:id", middleware.RequireAuth(), middleware.OnlyIntegerAsID(), joke.DeleteJoke)
2021-07-09 06:11:11 +00:00
return app
}