Week 14

News

We are back! A whole lot going on recently, most importantly Vapor 3 is tagged 🎉🎉🎉.

New Features

Add ContentTag

Additional overloads to req.content.encode(...) were added. These allow for custom coders to be passed in as needed.

vapor/vapor#1648

Add support for parsing header value params without =

Useful for parsing cookies

vapor/core#131

Add types for working with MIME

Added MediaType, HeaderValue, CaseInsensitiveString and File for content-type.

vapor/core#127

Add ‘NestedData’ protocol

Adds NestedData: a data structure containing arbitrarily nested arrays and dictionaries

vapor/core#126

Add Thread.async(_:) method

Runs the supplied closure on a new thread. Calls Thread.detachNewThread(_:)

vapor/core#121

Adds Data Coders

A type capable of decoding Decodabletypes from Data.

vapor/core#108

Add a new future debug

Add debugging to future creation

vapor/core#101

Add a migration function name

Adds the ability to name migrations and to create migrations easily by just adding a closure

vapor/fluent#428

Adds a support for the deprecated flag

Adds support for the command’s flag with the form --option=value

vapor/console#63

NIO

Optimize for HTTP/1.1 and HTTP/1.0 responses

Motivation:

Its very likely that the response will be HTTP/1.1 or HTTP/1.0 so we can optimize for it by minimizing the buffer.write(…) calls. Beside this we should also change the pattern of *.write(into: inout ByteBuffer) to extension on ByteBuffer itself.

Modifications:

Result:

Faster and more clean code.

apple/swift-nio#300

Add support for automatic HTTP error reporting

Motivation:

Currently the HTTP decoders can throw errors, but they will be ignored and lead to a simple EOF. That’s not ideal: in most cases we should make a best-effort attempt to send a 4XX error code before we shut the client down.

Modifications:

Provided a new ChannelHandler that generates 400 errors when the HTTP decoder fails. Added a flag to automatically add that handler to the channel pipeline. Added the handler to the HTTP sample server. Enabled integration test 12.

Result:

Easier error handling for HTTP servers.

apple/swift-nio#268

Community Contributions

Ruby-on-Rails benchmark

@grundoon

vapor/benchmarks#1

Added guard for invalid cost

Related to vapor/crypto#57

@bre7

vapor/crypto#58

Add the required imports for the sample user model

@natebird

vapor/documentation#308

Fix a memory leak in QueueHandler

@MrMage

vapor/core#134

Follow API change in Crypto

@t-ae

vapor/core#167

Add extra HTTPHeaders to WebSocket client

@pvels

vapor/websocket#2

Adds git hash capability to vapor cloud

Adds vapor cloud git-hash

@joscdk

vapor/toolbox#221

Adding Host header to requests

@givip

vapor/http#269

Fixed FormURLEncoded Decoder Media Type Check

@calebkleveter

vapor/http#266

Adds TLS to HTTPClient

@vkill

vapor/http#260

Fix Timestampable when the models are structs

ccrazy88

vapor/fluent#445

Fix MySQL transaction support

@jseibert

vapor/fluent-mysql#100

Release pooled conn when catch for requestPooledConnection

@vkill

vapor/database-kit#25

Add url config to redis

@pedantix

vapor/redis#99

Fix synchronization issue in QueueHandler

@jseibert

vapor/core#118

Fix infinite recursion in MySQLCharacterSet.description

@jseibert

vapor/mysql#155

Fixed issue with EventLoop assert

When sending asynchronously a ByteBuffer in a WebSocket, it fails since the current execution is not in the same EventLoop as the WebSocket handler.

@kikettas

apor/http#254

Fix Cloud.yml

Fix the cloud.yml file so it uses the latest commands required to run an app

@0xTim

vapor/api-template#55

Export Async to avoid an import when conforming to Fluent protocols

@0xTim

vapor/fluent#417

Default port in MySQLDatabaseConfig to 3306

@0xTim

vapor/mysql#146

Fix MySQL index syntax

@jseibert

vapor/fluent-mysql#88

Tagged releases

Articles

Long article on starting with Vapor for Laravel developers

Vapor for Laravel Developer

Sending multiple requests to different DBs using an array of Future

Brought to you by Ralph Küepper

Vapor 3 Quick Case Study

Big list of tutorials (very good, huge shoutout to Mihaela)

Brought to you by @mihaelamj

Vapor 3 tutorials

Talks

Tim Condon on Getting Started with Server Side Swift with Vapor@CODEMOBILE

Tim Condon at CODEMOBILE

Kickstarting a project with Vapor 3 including CRUD operations

Brought to you by Vina Ranti @Engineers.SG

Kickstart a project with Vapor 3

Writing Credits

@frivas

@twof