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 of Session is created, then it is connected to the desired path. Two route to are then registered that save and retrieve a User from the session.

    Usage Example:

    let 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()
    }
    
    See more

    Declaration

    Swift

    public class Session : RouterMiddleware
  • A set of helper functions to manipulate session data.

    See more

    Declaration

    Swift

    public class SessionState