listsendpoint.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package api
  2. import (
  3. "net/http"
  4. "github.com/go-chi/chi"
  5. "github.com/go-chi/render"
  6. "github.com/willie68/schematic-service-go/dao"
  7. )
  8. // TagsRoutes getting all routes for the tags endpoint
  9. func TagsRoutes() *chi.Mux {
  10. router := chi.NewRouter()
  11. router.Get("/", GetTagsEndpoint)
  12. router.Get("/count", GetTagsCountEndpoint)
  13. return router
  14. }
  15. // ManufacturersRoutes getting all routes for the manufacturers endpoint
  16. func ManufacturersRoutes() *chi.Mux {
  17. router := chi.NewRouter()
  18. router.Get("/", GetManufacturersEndpoint)
  19. router.Get("/count", GetManufacturersCountEndpoint)
  20. return router
  21. }
  22. //GetTagsEndpoint getting all tags back. No paging...
  23. func GetTagsEndpoint(response http.ResponseWriter, req *http.Request) {
  24. tags := dao.GetTags()
  25. render.JSON(response, req, tags)
  26. }
  27. //GetManufacturersEndpoint getting all manufacturers back. No paging...
  28. func GetManufacturersEndpoint(response http.ResponseWriter, req *http.Request) {
  29. manufacturers := dao.GetManufacturers()
  30. render.JSON(response, req, manufacturers)
  31. }
  32. //GetTagsCountEndpoint getting all tags back. No paging...
  33. func GetTagsCountEndpoint(response http.ResponseWriter, req *http.Request) {
  34. tagsCount := dao.GetTagsCount()
  35. render.JSON(response, req, tagsCount)
  36. }
  37. //GetManufacturersCountEndpoint getting all manufacturers back. No paging...
  38. func GetManufacturersCountEndpoint(response http.ResponseWriter, req *http.Request) {
  39. manufacturersCount := dao.GetManufacturersCount()
  40. render.JSON(response, req, manufacturersCount)
  41. }