Skip to content

Commit

Permalink
Fixup issues in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Oct 26, 2024
1 parent e2550be commit 3752f85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 6 additions & 3 deletions Sources/Hummingbird/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ public struct Environment: Sendable, Decodable, ExpressibleByDictionaryLiteral {

var values: [String: String]

/// initialize from environment variables
/// Initialize from environment variables
public init() {
self.values = Self.getEnvironment()
}

/// initialize from dictionary
/// Initialize from dictionary
public init(values: [String: String]) {
self.values = Self.getEnvironment()
for (key, value) in values {
self.values[key.lowercased()] = value
}
}

/// initialize from dictionary literal
/// Initialize from dictionary literal
public init(dictionaryLiteral elements: (String, String)...) {
self.values = Self.getEnvironment()
for element in elements {
Expand Down Expand Up @@ -88,6 +88,9 @@ public struct Environment: Sendable, Decodable, ExpressibleByDictionaryLiteral {
}

/// Set environment variable
///
/// This sets the variable within this type and also calls `setenv` so future versions
/// of this type will also have this variable set.
/// - Parameters:
/// - s: Environment variable name
/// - value: Environment variable name value
Expand Down
14 changes: 12 additions & 2 deletions Sources/Hummingbird/Server/ChildRequestContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@
//===----------------------------------------------------------------------===//
import Logging

/// A RequestContext that can be initialized from another RequestContext where initialization
/// can throw errors which will be passed back up the middleware stack
/// A RequestContext that can be initialized from another RequestContext.
///
/// The init for the context is marked throwing as it is allowed to fail. If
/// it fails then the error is passed back up the middleware stack
///
/// ```
/// struct MyRequestContext: ChildRequestContext {
/// init(context: MyParentRequestContext) throws {
/// self.coreContext = context.coreContext
/// }
/// }
/// ```
public protocol ChildRequestContext<ParentContext>: RequestContext where Source == Never {
associatedtype ParentContext: RequestContext
/// Initialise RequestContext from source
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hummingbird/Utils/InitializableFromSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
/// A type that can be initialized from another type
public protocol InitializableFromSource<Source>: Sendable {
associatedtype Source
/// Initialise RequestContext from source
/// Initialise from source type
init(source: Source)
}

0 comments on commit 3752f85

Please sign in to comment.