12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package routes
- import (
- "github.com/gofiber/fiber/v2"
- "github.com/gofiber/fiber/v2/middleware/cors"
- jwtware "github.com/gofiber/jwt/v3"
- "notabug.org/alimiracle/my-website-api/handlers"
- )
- func SetupRoutes(app *fiber.App) {
- handler := handlers.Init()
- api := app.Group("/api")
- app.Use(cors.New())
- api.Get("/projects", handler.GetAllProjects)
- api.Get("/skills", handler.GetAllSkills)
- api.Get("/jobs", handler.GetAllJobs)
- api.Get("/contacts", handler.GetAllContacts)
- api.Get("/users", handler.GetAllUsers)
- api.Post("/login", handler.Login)
- // JWT Middleware
- app.Use(jwtware.New(jwtware.Config{
- SigningKey: []byte("secret"),
- }))
- api.Post("/projects", handler.AddProject)
- api.Post("/skills", handler.AddSkill)
- api.Post("/jobs", handler.AddJob)
- api.Post("/users", handler.AddUser)
- api.Put("/projects/:id", handler.UpdateProject)
- api.Put("/skills/:id", handler.UpdateSkill)
- api.Put("/jobs/:id", handler.UpdateJob)
- api.Put("/contacts/:id", handler.UpdateContact)
- api.Put("/users/:id", handler.UpdateUser)
- api.Delete("/projects/:id", handler.DeleteProject)
- api.Delete("/jobs/:id", handler.DeleteJob)
- api.Delete("/skills/:id", handler.DeleteSkill)
- api.Delete("/contacts/:id", handler.DeleteContact)
- api.Delete("/users/:id", handler.DeleteUser)
- }
|