Created
May 31, 2018 14:10
-
-
Save hsharghi/12180ff80cd4b25798a9911b6936e50c to your computer and use it in GitHub Desktop.
UserController-00.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import Crypto // 1 | |
/// Controls basic CRUD operations on `User`s. | |
final class UserController: RouteCollection { | |
func boot(router: Router) throws { | |
let users = router.grouped("users") // 2 | |
users.get(use: index) | |
users.get(User.parameter, use: show) // 3 | |
users.post(use: create) | |
users.patch(User.parameter, use: update) | |
users.delete(User.parameter, use: delete) | |
} | |
// 4 | |
func index(_ req: Request) throws -> Future<[User]> { | |
} | |
func show(_ req: Request) throws -> Future<User> { | |
} | |
func create(_ req: Request) throws -> Future<User> { | |
} | |
func update(_ req: Request) throws -> Future<User> { | |
} | |
func delete(_ req: Request) throws -> Future<HTTPStatus> { | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment