Skip to content

Commit be5cac9

Browse files
authored
FoundationEssentials (#50)
* FoundationEssentials Add percentEncode functions from Foundation Replace Foundation imports with FoundationEssentials * import Dispatch * Include notice detailing code from swift-foundation * Use runtime beta 2 * Copyright 2025
1 parent 8893bdb commit be5cac9

22 files changed

+565
-49
lines changed

NOTICE.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
The Hummingbird Project
2+
====================
3+
4+
Please visit the Hummingbird web site for more information:
5+
6+
* https://hummingbird.codes
7+
8+
Copyright 2024 The Hummingbird Project
9+
10+
The Hummingbird Project licenses this file to you under the Apache License,
11+
version 2.0 (the "License"); you may not use this file except in compliance
12+
with the License. You may obtain a copy of the License at:
13+
14+
https://www.apache.org/licenses/LICENSE-2.0
15+
16+
Unless required by applicable law or agreed to in writing, software
17+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
License for the specific language governing permissions and limitations
20+
under the License.
21+
22+
-------------------------------------------------------------------------------
23+
24+
This product contains code from swift-foundation.
25+
26+
* LICENSE (MIT):
27+
* https://github.com/swiftlang/swift-foundation/blob/main/LICENSE.md
28+
* HOMEPAGE:
29+
* https://github.com/swiftlang/swift-foundation/
30+

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ let package = Package(
1313
.executable(name: "HBLambdaTest", targets: ["HBLambdaTest"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "2.0.0-beta"),
16+
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "2.0.0-beta.2"),
1717
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "1.0.0"),
1818
.package(url: "https://github.com/swift-extras/swift-extras-base64.git", from: "1.0.0"),
19-
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.9.0"),
19+
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.15.0"),
2020
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
2121
],
2222
targets: [

Sources/HummingbirdLambda/APIGatewayLambda.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2021-2024 the Hummingbird authors
5+
// Copyright (c) 2021-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -33,19 +33,16 @@ where Responder.Context: InitializableFromSource<LambdaRequestContextSource<APIG
3333
// conform `APIGatewayRequest` to `APIRequest` so we can use Request.init(context:application:from)
3434
extension APIGatewayRequest: APIRequest {
3535
var queryString: String {
36-
func urlPercentEncoded(_ string: String) -> String {
37-
return string.addingPercentEncoding(withAllowedCharacters: .urlQueryComponentAllowed) ?? string
38-
}
3936
var queryParams: [String] = []
4037
var queryStringParameters = self.queryStringParameters
4138
// go through list of multi value query string params first, removing any
4239
// from the single value list if they are found in the multi value list
4340
for (key, value) in self.multiValueQueryStringParameters {
4441
queryStringParameters[key] = nil
45-
queryParams += value.map { "\(urlPercentEncoded(key))=\(urlPercentEncoded($0))" }
42+
queryParams += value.map { "\(key.addingPercentEncoding(forURLComponent: .query))=\($0.addingPercentEncoding(forURLComponent: .query))" }
4643
}
4744
queryParams += queryStringParameters.map {
48-
"\(urlPercentEncoded($0.key))=\(urlPercentEncoded($0.value))"
45+
"\($0.key.addingPercentEncoding(forURLComponent: .query))=\($0.value.addingPercentEncoding(forURLComponent: .query))"
4946
}
5047
return queryParams.joined(separator: "&")
5148
}

Sources/HummingbirdLambda/APIGatewayV2Lambda.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2021-2024 the Hummingbird authors
5+
// Copyright (c) 2021-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Sources/HummingbirdLambda/BasicLambdaRequestContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2024 the Hummingbird authors
5+
// Copyright (c) 2024-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Sources/HummingbirdLambda/CollateResponseBodyWriter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2023 the Hummingbird authors
5+
// Copyright (c) 2023-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Sources/HummingbirdLambda/Deprecations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2024 the Hummingbird authors
5+
// Copyright (c) 2024-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Sources/HummingbirdLambda/Exports.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2023 the Hummingbird authors
5+
// Copyright (c) 2023-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

Sources/HummingbirdLambda/FunctionURLLambda.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2021-2024 the Hummingbird authors
5+
// Copyright (c) 2021-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -58,6 +58,6 @@ extension FunctionURLResponse: APIResponse {
5858
isBase64Encoded: Bool?
5959
) {
6060
precondition(multiValueHeaders == nil || multiValueHeaders?.isEmpty == true, "Multi value headers are unavailable in FunctionURL")
61-
self.init(statusCode: statusCode, headers: headers, body: body, cookies: nil, isBase64Encoded: isBase64Encoded)
61+
self.init(statusCode: statusCode, headers: headers, body: body, isBase64Encoded: isBase64Encoded, cookies: nil)
6262
}
6363
}

Sources/HummingbirdLambda/LambdaFunction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Hummingbird server framework project
44
//
5-
// Copyright (c) 2023-2024 the Hummingbird authors
5+
// Copyright (c) 2023-2025 the Hummingbird authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information

0 commit comments

Comments
 (0)