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 queryVapor.Request
now wraps the renamedHTTPRequest
(which is now a struct as well)Middleware
andResponder
are nowVapor.*
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
andContainer
.EventLoop
is now a protocol andContainer
conforms by default.Extendable
has been moved toCore
. - 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 nowreq.content.encode/decode
to match query- Fluent model IDs now auto-increment correctly
Changed:
- Instead of
make
ing 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)
...
}