routes.go 839 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package main
  2. import (
  3. "net/http"
  4. "rate-it-api/controllers"
  5. )
  6. // Route struct defining Route type
  7. type Route struct {
  8. Name string
  9. Method string
  10. Pattern string
  11. HandlerFunc http.HandlerFunc
  12. }
  13. // Routes collection of Route
  14. type Routes []Route
  15. var routes = Routes{
  16. Route{
  17. "Index",
  18. "GET",
  19. "/",
  20. controllers.Index,
  21. },
  22. Route{
  23. "AuthToken",
  24. "POST",
  25. "/auth",
  26. controllers.AuthToken,
  27. },
  28. Route{
  29. "UserCreate",
  30. "POST",
  31. "/user",
  32. controllers.UserCreate,
  33. },
  34. Route{
  35. "UserValidate",
  36. "GET",
  37. "/user/validation/{uuid}",
  38. controllers.UserValidate,
  39. },
  40. }
  41. // routesJwt routes protected by a JSON Web Token Authentification
  42. var routesJwt = Routes{
  43. Route{
  44. "TodoIndex",
  45. "GET",
  46. "/todos",
  47. controllers.TodoIndex,
  48. },
  49. Route{
  50. "TodoShow",
  51. "GET",
  52. "/todos/{todoId}",
  53. controllers.TodoShow,
  54. },
  55. }