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

28 lines
490 B
Go
Raw Normal View History

2021-08-04 02:51:22 +00:00
package routes
import (
"jokes-bapak2-api/app/v1/handler/submit"
2021-08-04 09:03:53 +00:00
"time"
2021-08-04 02:51:22 +00:00
"github.com/gofiber/fiber/v2"
2021-08-04 09:03:53 +00:00
"github.com/gofiber/fiber/v2/middleware/cache"
2021-08-04 02:51:22 +00:00
)
func Submit(app *fiber.App) *fiber.App {
// Get pending submitted joke
2021-08-04 09:03:53 +00:00
app.Get(
"/submit",
cache.New(cache.Config{
Expiration: 5 * time.Minute,
KeyGenerator: func(c *fiber.Ctx) string {
return c.OriginalURL()
},
}),
submit.GetSubmission)
2021-08-04 02:51:22 +00:00
// Add a joke
app.Post("/submit", submit.SubmitJoke)
return app
}