github vapor/vapor 4.36.0
Rework 'SessionData' to be more friendly to 2nd party devs

latest releases: 4.95.0, 4.94.1, 4.94.0...
3 years ago
This patch was authored and released by @Mordil.

As reported by #2480, right now SessionData is a public type without much use to developers to write middleware, algorithms, etc. on top of due to how strongly the storage is encapsulated.

SessionData has been changed as follows:

  • Now conforms to Equatable and ExpressibleByDictionaryLiteral
  • A new snapshot computed property is available to get a copy of its storage
  • init(_:) is now deprecated in favor of init(initialData:)
let data: SessionData = ["name": "Vapor"]
// creates a copy of the data as of this point
let snapshot = data.snapshot
client.storeUsingDictionary(snapshot)

Don't miss a new vapor release

NewReleases is sending notifications on new releases.