Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

60 wiersze
1.6 KiB

  1. import Vapor
  2. func routes(_ app: Application) throws {
  3. app.routes.caseInsensitive = true
  4. app.routes.defaultMaxBodySize = "64mb";
  5. let v2 = app.grouped("api").grouped("v2")
  6. try v2.register(collection: FuelEntryV2Controller())
  7. try v2.register(collection: UserController())
  8. let fuelEntryController = FuelEntryController()
  9. app.get {
  10. req in return "Fueling API v2"
  11. }
  12. app.get("fuel-entries") { req in
  13. try await fuelEntryController.index(req: req)
  14. }
  15. app.post("fuel-entries") { req in
  16. try await fuelEntryController.create(req: req)
  17. }
  18. app.delete("fuel-entries", ":fuelEntryID") { req in
  19. try await fuelEntryController.delete(req: req)
  20. }
  21. // V2 API routes with image upload
  22. // let v2Routes: () = app.group("api", "v2") { v2 in
  23. // let fuelEntryV2Controller = FuelEntryV2Controller()
  24. //
  25. // v2.get("fuel-entries") {req in
  26. // try await fuelEntryV2Controller.index(req: req)
  27. // }
  28. //
  29. //// v2.get("fuel-entries", "with-images") {req in
  30. //// try await fuelEntryV2Controller.getAllEntriesWithImages(req: req)
  31. //// }
  32. //
  33. // v2.post("fuel-entries") {req in
  34. // try await fuelEntryV2Controller.create(req: req)
  35. // }
  36. //
  37. //// v2.post("fuel-entries", ":id", "upload-image") { req -> FuelEntry in
  38. //// return try await fuelEntryV2Controller.uploadImage(req: req)
  39. //// }
  40. //
  41. // v2.delete("fuel-entries", ":fuelEntryID") { req in
  42. // try await fuelEntryV2Controller.delete(req: req)
  43. // }
  44. // }
  45. }