- Download latest "Swift 4.1 Development" snapshot from Swift.org Snapshots.
- Open downloaded
.pkgfile to install. - Xcode > Toolchains > Swift 4.1 Snapshot
| r.get("posts", ":postID") { req in | |
| let postID = try req.parameters.get(":postID") | |
| print(postID) // String | |
| ... | |
| } | |
| enum PathComponent { | |
| case part(String) | |
| case dynamic(name: String) | |
| case anything |
| ==27371== | |
| ==27371== Process terminating with default action of signal 2 (SIGINT) | |
| ==27371== at 0x53659F3: futex_wait_cancelable (futex-internal.h:88) | |
| ==27371== by 0x53659F3: __pthread_cond_wait_common (pthread_cond_wait.c:502) | |
| ==27371== by 0x53659F3: pthread_cond_wait@@GLIBC_2.3.2 (pthread_cond_wait.c:655) | |
| ==27371== by 0x3FD1DC: $s21NIOConcurrencyHelpers13ConditionLockC4lock9whenValueyx_tF (in /home/tanner/dev/sandbox/vapor-memory-leak/.build/x86_64-unknown-linux/release/Run) | |
| ==27371== by 0x3A812C: $s3NIO15EventLoopFutureC4wait4file4linexs12StaticStringV_SutKF (in /home/tanner/dev/sandbox/vapor-memory-leak/.build/x86_64-unknown-linux/release/Run) | |
| ==27371== by 0x4FDD3C: $s5Vapor11ApplicationC3runyyKF (in /home/tanner/dev/sandbox/vapor-memory-leak/.build/x86_64-unknown-linux/release/Run) | |
| ==27371== by 0x463610: main (in /home/tanner/dev/sandbox/vapor-memory-leak/.build/x86_64-unknown-linux/release/Run) | |
| ==27371== |
| import Vapor | |
| public func routes(_ router: Router) throws { | |
| router.get("streaming") { req -> Future<Response> in | |
| // URL to test file that will be downloaded | |
| // https://speed.hetzner.de/100MB.bin | |
| // https://speed.hetzner.de/10GB.bin | |
| let testFile = URL(string: "https://speed.hetzner.de/100MB.bin")! | |
| // create an instance of our URL session delegate |
| # echo current git branch | |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/' | |
| } | |
| # echo "*" if git status is unclean | |
| parse_git_status() { | |
| GIT_STATUS="$(git status 2>&1)" | |
| if [[ $GIT_STATUS != *"clean"* ]] && | |
| [[ $GIT_STATUS != *"not a git repository"* ]]; |
| /// Aliquam quis dolor tristique, vulputate lectus id, maximus ipsum. | |
| /// Fusce placerat metus sed luctus posuere. Phasellus ultrices iaculis diam, | |
| /// sit amet volutpat urna elementum sed. | |
| final class Clarity: Model { | |
| /// Aliquam quis dolor tristique, vulputate lectus id, maximus ipsum. | |
| /// Fusce placerat metus sed luctus posuere. Phasellus ultrices iaculis diam, | |
| /// sit amet volutpat urna elementum sed. | |
| @ID(key: "at", generatedBy: .user) | |
| var id: Date? |
| protocol HookEvent { } | |
| protocol HookEventHandler { | |
| func handle(_ event: HookEvent) | |
| } | |
| protocol DiscordEventHandler: HookEventHandler { | |
| func handle(_ event: DiscordEvent) | |
| } |
We've been working on the fourth major release of Vapor for almost a year now. The first alpha version was tagged last May, with the first beta following in October. During that time, the community has done amazing work helping to test, improve, and refine this release. Over 500 issues and pull requests have been closed so far!
Looking back at Vapor 3's pre-release timeline, 7 months passed between alpha.1 and the final release. If history repeats itself, we would reach 4.0.0 sometime in February 2020.
As we near the end of the active development phase, efforts are shifting toward a focus on documentation and polish. Since APIs have mostly settled down at this point, I'd like to take this opportunity to introduce you to some of the exciting changes coming in Vapor 4. Let's dive in.
| import Fluent | |
| import Vapor | |
| func routes(_ app: Application) throws { | |
| app.post("users") { req -> EventLoopFuture<User> in | |
| try User.Create.validate(req) | |
| let create = try req.content.decode(User.Create.self) | |
| guard create.password == create.confirmPassword else { | |
| throw Abort(.badRequest, reason: "Passwords did not match") | |
| } |
| enum FujiMessage { | |
| case credentials(username: String, password: String) | |
| case didCreatePart(barcode: String) | |
| case success(message: String) | |
| case error(message: String) | |
| } | |
| protocol FujiConnection { | |
| func send(message: FujiMessage) | |
| } |