Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

54 строки
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("fuel-entries") { req in
  10. try await fuelEntryController.index(req: req)
  11. }
  12. app.post("fuel-entries") { req in
  13. try await fuelEntryController.create(req: req)
  14. }
  15. app.delete("fuel-entries", ":fuelEntryID") { req in
  16. try await fuelEntryController.delete(req: req)
  17. }
  18. // V2 API routes with image upload
  19. // let v2Routes: () = app.group("api", "v2") { v2 in
  20. // let fuelEntryV2Controller = FuelEntryV2Controller()
  21. //
  22. // v2.get("fuel-entries") {req in
  23. // try await fuelEntryV2Controller.index(req: req)
  24. // }
  25. //
  26. //// v2.get("fuel-entries", "with-images") {req in
  27. //// try await fuelEntryV2Controller.getAllEntriesWithImages(req: req)
  28. //// }
  29. //
  30. // v2.post("fuel-entries") {req in
  31. // try await fuelEntryV2Controller.create(req: req)
  32. // }
  33. //
  34. //// v2.post("fuel-entries", ":id", "upload-image") { req -> FuelEntry in
  35. //// return try await fuelEntryV2Controller.uploadImage(req: req)
  36. //// }
  37. //
  38. // v2.delete("fuel-entries", ":fuelEntryID") { req in
  39. // try await fuelEntryV2Controller.delete(req: req)
  40. // }
  41. // }
  42. }