Skip to content

Commit

Permalink
Update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Jan 23, 2024
1 parent 8708bbe commit 4f04aab
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Sources/HummingbirdAuth/Sessions/SessionStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ public struct HBSessionStorage: Sendable {

/// save new or exising session
///
/// Saving a new session will create a new session id and save that to the
/// response. Thus a route that uses `save` needs to have the `.editResponse`
/// option set. If you know the session already exists consider using
/// `update` instead.
/// Saving a new session will create a new session id and returns a cookie setting
/// the session id. You need to then return a response including this cookie. You
/// can either create an ``HBResponse`` directly or use ``HBEditedResponse`` to
/// generate the response from another type.
/// ```swift
/// let cookie = try await sessionStorage.save(session: session, expiresIn: .seconds(600))
/// var response = HBEditedResponse(response: responseGenerator)
/// response.setCookie(cookie)
/// return response
/// ```
/// If you know a session already exists it is preferable to use
/// ``HBSessionStorage/update(session:expiresIn:request:)``.
public func save<Session: Codable>(session: Session, expiresIn: Duration) async throws -> HBCookie {
let sessionId = Self.createSessionId()
// prefix with "hbs."
Expand Down

0 comments on commit 4f04aab

Please sign in to comment.