github vapor/vapor 3.0.0-alpha.5
Vapor 3.0 Alpha 5

latest releases: 4.96.0, 4.95.0, 4.94.1...
pre-release6 years ago

Comparing 3.0.0-alpha.4...3.0.0-alpha.5

Showing 298 changed files with 10,248 additions and 3,854 deletions.

New:

  • FluentMySQL package has been added and is ready to use.
  • HTTP2 client. Convenience APIs coming soon.
  • FormURLEncoder/Decoder. These have been added to ContentConfig and are ready to use
  • req.query.decode() for decoding content from the URI query
  • Vapor.Request now wraps the renamed HTTPRequest (which is now a struct as well)
  • Middleware and Responder are now Vapor.* types
  • New response disambiguation helper AnyResponse
  • req.redirect(to:) helper
  • Overloads for null context on view renderer.
  • There are now three tiers of containers: Application -> EventLoop -> Request. (See below)

Fixed:

  • Improvements to EventLoop and Container. EventLoop is now a protocol and Container conforms by default. Extendable has been moved to Core.
  • Leaf now uses #get/#set/#embed (instead of raw/import/export)
  • Leaf now runs #if tags if the statement is not nil (or is a bool == true)
  • req.content() is now req.content.encode/decode to match query
  • Fluent model IDs now auto-increment correctly

Changed:

  • Instead of makeing a router and adding routes, you now create your own router (manually) and register the router to Services.

Router changes

let router = EngineRouter.default()

router.get("api", "v1", "users") { req in
  return Response(status: 404)
}

services.register(Router.self, router)

Container updates

There are now 3 types of containers. Here is the hierarchy:

Application -> EventLoop -> Request

Use the app to create thread-safe, sharable services you need during a request (or of course services you need only during boot).

let foo = try app.make(Foo.self) // assume Foo is some threadsafe, shareable service
print(foo)

router.get("foo") { req in
    return foo.bar()
}

Use the eventLoop to create non-threadsafe, sharable services you need during a request.

note: sharing non-threadsafe (little overhead) resources on a single thread yields great performance. you should the eventLoop to create services where possible.

router.get("foo") { req in
    return req.eventLoop.make(ViewRenderer.self).make(...)
}

Use the request to create non-threadsafe, non-sharable services you need during a request.

router.get("foo") { req in
    let auth = req.make(AuthHelper.self)
    ...
}

Don't miss a new vapor release

NewReleases is sending notifications on new releases.