Vapor v4.0.0-alpha.3 Release Notes
Release Date: 2019-08-26 // over 4 years ago-
Request
no longer requires aChannel
to init. Now, it requires anEventLoop
andSocketAddress?
. (#2037)
โ > Note: This makes testing a
Request
easier since you can pass in eitherEmbeddedEventLoop
or a real event loop from a group used elsewhere in your tests. Prior to this change, you were required to useEmbeddedChannel
andEmbeddedEventLoop
both of which are incompatible with real event loops.๐ > Note:
Application.running
allows you to programmatically shutdown your HTTP server from anywhere that you can accessApplication
. 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)