- 0.4.0 and master18.104.22.168.04.2
- 0.4.0 and masteriOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
This package works as a replacement for
request.storage which was available in Vapor 1 & 2.
Add the package declaration to your project's manifest
.package(url: "https://github.com/skelpo/vapor-request-storage.git", from: "0.1.0")
Then add the
VaporRequestStorage to the
dependencies array of any target you want access to it in.
Complete the installation by running
vapor update or
swift package update from the command-line.
configure.swift file, import
VaporRequestStorage. Then register the provider with the
services object passed into the
You can now use the
Storage service and a
privateContainer to store data in a request.
To set a value, there is a
try request.set("key", to: value)
To get the value later, use the
try request.get("key", as: Value.self)
The second parameter of the
get method has a default value of
Stored.self, which means if you specify the return type somewhere else, you can skip passing that value in:
let value: Value = try request.get("key")