Vapor v4.0.0-alpha.3 Release Notes

Release Date: 2019-08-26 // over 4 years ago
    • 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 inreturn req.parameters.get("a") ?? "" } r.get("hello", ":a", ":b") { req inreturn [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 inXCTAssertEqual(res.status, .ok) XCTAssertContains(res.body.string, "vapor") }.test(.POST, "/hello/vapor") { res inXCTAssertEqual(res.status, .notFound) }.test(.GET, "/hello/vapor/development") { res inXCTAssertEqual(res.status, .ok) XCTAssertEqual(res.body.string, #"["vapor","development"]"#) }
    
    • ๐Ÿ›  Fixed an issue causing Request.query.get / Request.query.subscript to crash. (#2018)