import Vapor private func register(_ req: Request, isAttending: Bool) -> String { guard let name = req.body.string?.trimmingCharacters(in: .whitespacesAndNewlines) else { return "No Name" } if isAttending { return add(guest: name) } else { return remove(guest: name) } } func routes(_ app: Application) throws { app.get("festival", "api", "ping") { req in return "It works!" } app.get("festival", "api", "count") { req in return "\(guestCount())" } app.post("festival", "api", "register") { req -> String in register(req, isAttending: true) } app.post("festival", "api", "decline") { req -> String in register(req, isAttending: false) } }