Vapor: 4.0.0-alpha.3 Release

Release date:
August 26, 2019
Previous version:
4.0.0-alpha.2.1 (released August 22, 2019)
Magnitude:
46 Diff Delta
Contributors:
2 total committers
Data confidence:
Commits:

Top Contributors in 4.0.0-alpha.3

vkill
tanner-nelson-c9fa

Directory Browser for 4.0.0-alpha.3

We haven't yet finished calculating and confirming the files and directories changed in this release. Please check back soon.

Release Notes Published

  • Request no longer requires a Channel to init. Now, it requires an EventLoop and SocketAddress?. (#2037)

Note: This makes testing a Request easier since you can pass in either EmbeddedEventLoop or a real event loop from a group used elsewhere in your tests. Prior to this change, you were required to use EmbeddedChannel and EmbeddedEventLoop both of which are incompatible with real event loops.

  • Fixed a data race accessing Application.running. (#2027, #2037)

Note: Application.running allows you to programmatically shutdown your HTTP server from anywhere that you can access Application. This includes routes, commands, etc. Because this can be accessed from any thread, it required synchronization (NSLock) to access.

  • XCTApplication test helpers now require explicit start / shutdown. (#2037)

Note: Although a bit more verbose, explicitly starting and shutting down test helpers gives the user more options for how they test their application. It also cuts down on edge cases in the testing implementation.

Example from Vapor's tests with explicit start / shutdown:

let app = Application.create(routes: { r, c in
    r.get("hello", ":a") { req in
        return req.parameters.get("a") ?? ""
    }

    r.get("hello", ":a", ":b") { req in
        return [req.parameters.get("a") ?? "", req.parameters.get("b") ?? ""]
    }
})
defer { app.shutdown() }

let server = try app.testable().start()
defer { server.shutdown() }

try server.test(.GET, "/hello/vapor") { res in
    XCTAssertEqual(res.status, .ok)
    XCTAssertContains(res.body.string, "vapor")
}.test(.POST, "/hello/vapor") { res in
    XCTAssertEqual(res.status, .notFound)
}.test(.GET, "/hello/vapor/development") { res in
    XCTAssertEqual(res.status, .ok)
    XCTAssertEqual(res.body.string, #"["vapor","development"]"#)
}
  • Fixed an issue causing Request.query.get / Request.query.subscript to crash. (#2018)