Skip to content

Commit

Permalink
Rename CoreRequestContext to CoreRequestContextStorage (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Jun 15, 2024
1 parent ec1bc51 commit b2fdf6c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
6 changes: 4 additions & 2 deletions Sources/Hummingbird/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public typealias HBFileIO = FileIO
public typealias HBBaseRequestContext = RequestContext
@_documentation(visibility: internal) @available(*, deprecated, renamed: "BasicRequestContext")
public typealias HBBasicRequestContext = BasicRequestContext
@_documentation(visibility: internal) @available(*, deprecated, renamed: "CoreRequestContext")
public typealias HBCoreRequestContext = CoreRequestContext
@_documentation(visibility: internal) @available(*, deprecated, renamed: "CoreRequestContextStorage")
public typealias HBCoreRequestContext = CoreRequestContextStorage
@_documentation(visibility: internal) @available(*, deprecated, renamed: "CoreRequestContextStorage")
public typealias CoreRequestContext = CoreRequestContextStorage
@_documentation(visibility: internal) @available(*, deprecated, renamed: "RequestContext")
public typealias HBRequestContext = RequestContext
@_documentation(visibility: internal) @available(*, deprecated, renamed: "RequestDecoder")
Expand Down
6 changes: 3 additions & 3 deletions Sources/Hummingbird/Server/RequestContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public struct ServerRequestContextSource: RequestContextSource {
}

/// Request context values required by Hummingbird itself.
public struct CoreRequestContext: Sendable {
public struct CoreRequestContextStorage: Sendable {
/// ByteBuffer allocator used by request
@usableFromInline
let allocator: ByteBufferAllocator
Expand Down Expand Up @@ -93,7 +93,7 @@ public protocol RequestContext: InstantiableRequestContext {
associatedtype Encoder: ResponseEncoder = JSONEncoder

/// Core context
var coreContext: CoreRequestContext { get set }
var coreContext: CoreRequestContextStorage { get set }
/// Maximum upload size allowed for routes that don't stream the request payload. This
/// limits how much memory would be used for one request
var maxUploadSize: Int { get }
Expand Down Expand Up @@ -146,7 +146,7 @@ extension RequestContext where Encoder == JSONEncoder {
/// Implementation of a basic request context that supports everything the Hummingbird library needs
public struct BasicRequestContext: RequestContext {
/// core context
public var coreContext: CoreRequestContext
public var coreContext: CoreRequestContextStorage

/// Initialize an `RequestContext`
/// - Parameters:
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdRouter/RouterBuilderContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public protocol RouterRequestContext: RequestContext {
/// Basic implementation of a context that can be used with `RouterBuilder``
public struct BasicRouterRequestContext: RequestContext, RouterRequestContext {
public var routerContext: RouterBuilderContext
public var coreContext: CoreRequestContext
public var coreContext: CoreRequestContextStorage

public init(source: Source) {
self.coreContext = .init(source: source)
Expand Down
2 changes: 1 addition & 1 deletion Tests/HummingbirdRouterTests/RouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public struct TestRouterContext2: RouterRequestContext, RequestContext {
/// router context
public var routerContext: RouterBuilderContext
/// core context
public var coreContext: CoreRequestContext
public var coreContext: CoreRequestContextStorage

/// additional data
public var string: String
Expand Down
6 changes: 3 additions & 3 deletions Tests/HummingbirdTests/ApplicationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ final class ApplicationTests: XCTestCase {

func testOptionalCodable() async throws {
struct SortedJSONRequestContext: RequestContext {
var coreContext: CoreRequestContext
var coreContext: CoreRequestContextStorage
var responseEncoder: JSONEncoder {
let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
Expand Down Expand Up @@ -453,7 +453,7 @@ final class ApplicationTests: XCTestCase {
self.coreContext = .init(source: source)
}

var coreContext: CoreRequestContext
var coreContext: CoreRequestContextStorage
var maxUploadSize: Int { 64 * 1024 }
}
let router = Router(context: MaxUploadRequestContext.self)
Expand Down Expand Up @@ -482,7 +482,7 @@ final class ApplicationTests: XCTestCase {
/// Implementation of a basic request context that supports everything the Hummingbird library needs
struct SocketAddressRequestContext: RequestContext {
/// core context
var coreContext: CoreRequestContext
var coreContext: CoreRequestContextStorage
// socket address
let remoteAddress: SocketAddress?

Expand Down
2 changes: 1 addition & 1 deletion Tests/HummingbirdTests/RouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ struct TestRouterContext2: RequestContext {
}

/// parameters
var coreContext: CoreRequestContext
var coreContext: CoreRequestContextStorage

/// additional data
var string: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HummingBirdURLEncodedTests: XCTestCase {
}

struct URLEncodedCodingRequestContext: RequestContext {
var coreContext: CoreRequestContext
var coreContext: CoreRequestContextStorage

init(source: Source) {
self.coreContext = .init(source: source)
Expand Down

0 comments on commit b2fdf6c

Please sign in to comment.