Classes
The following classes are available globally.
-
A pluggable middleware for managing user sessions.
In order to use the Session middleware, an instance of
Session
has to be created. In the example below an instance ofSession
is created, then it is connected to the desired path. Two route to are then registered that save and retrieve aUser
from the session.Usage Example:
See morelet session = Session(secret: "Something very secret") router.all(middleware: session) public struct User: Codable { let name: String } router.post("/user") { request, response, next in let user = User(name: "Kitura") request.session?["User"] = user next() } router.get("/user") { request, response, next in let user: User? = request.session?["Kitura"] next() }
Declaration
Swift
public class Session : RouterMiddleware
-
A set of helper functions to manipulate session data.
See moreDeclaration
Swift
public class SessionState