Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
The Hummingbird Project
====================

Please visit the Hummingbird web site for more information:

* https://hummingbird.codes

Copyright 2024 The Hummingbird Project

The Hummingbird Project licenses this file to you under the Apache License,
version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at:

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.

-------------------------------------------------------------------------------

This product contains code from swift-foundation.

* LICENSE (MIT):
* https://github.com/swiftlang/swift-foundation/blob/main/LICENSE.md
* HOMEPAGE:
* https://github.com/swiftlang/swift-foundation/

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ let package = Package(
.executable(name: "HBLambdaTest", targets: ["HBLambdaTest"]),
],
dependencies: [
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "2.0.0-beta"),
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "2.0.0-beta.2"),
.package(url: "https://github.com/swift-server/swift-aws-lambda-events.git", from: "1.0.0"),
.package(url: "https://github.com/swift-extras/swift-extras-base64.git", from: "1.0.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.9.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.15.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
],
targets: [
Expand Down
9 changes: 3 additions & 6 deletions Sources/HummingbirdLambda/APIGatewayLambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Copyright (c) 2021-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down Expand Up @@ -33,19 +33,16 @@ where Responder.Context: InitializableFromSource<LambdaRequestContextSource<APIG
// conform `APIGatewayRequest` to `APIRequest` so we can use Request.init(context:application:from)
extension APIGatewayRequest: APIRequest {
var queryString: String {
func urlPercentEncoded(_ string: String) -> String {
return string.addingPercentEncoding(withAllowedCharacters: .urlQueryComponentAllowed) ?? string
}
var queryParams: [String] = []
var queryStringParameters = self.queryStringParameters
// go through list of multi value query string params first, removing any
// from the single value list if they are found in the multi value list
for (key, value) in self.multiValueQueryStringParameters {
queryStringParameters[key] = nil
queryParams += value.map { "\(urlPercentEncoded(key))=\(urlPercentEncoded($0))" }
queryParams += value.map { "\(key.addingPercentEncoding(forURLComponent: .query))=\($0.addingPercentEncoding(forURLComponent: .query))" }
}
queryParams += queryStringParameters.map {
"\(urlPercentEncoded($0.key))=\(urlPercentEncoded($0.value))"
"\($0.key.addingPercentEncoding(forURLComponent: .query))=\($0.value.addingPercentEncoding(forURLComponent: .query))"
}
return queryParams.joined(separator: "&")
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdLambda/APIGatewayV2Lambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Copyright (c) 2021-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2024 the Hummingbird authors
// Copyright (c) 2024-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2023 the Hummingbird authors
// Copyright (c) 2023-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdLambda/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2024 the Hummingbird authors
// Copyright (c) 2024-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
2 changes: 1 addition & 1 deletion Sources/HummingbirdLambda/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2023 the Hummingbird authors
// Copyright (c) 2023-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
4 changes: 2 additions & 2 deletions Sources/HummingbirdLambda/FunctionURLLambda.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Copyright (c) 2021-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down Expand Up @@ -58,6 +58,6 @@ extension FunctionURLResponse: APIResponse {
isBase64Encoded: Bool?
) {
precondition(multiValueHeaders == nil || multiValueHeaders?.isEmpty == true, "Multi value headers are unavailable in FunctionURL")
self.init(statusCode: statusCode, headers: headers, body: body, cookies: nil, isBase64Encoded: isBase64Encoded)
self.init(statusCode: statusCode, headers: headers, body: body, isBase64Encoded: isBase64Encoded, cookies: nil)
}
}
2 changes: 1 addition & 1 deletion Sources/HummingbirdLambda/LambdaFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2023-2024 the Hummingbird authors
// Copyright (c) 2023-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down
14 changes: 14 additions & 0 deletions Sources/HummingbirdLambda/LambdaRequestContext.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2023-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

import AWSLambdaRuntime
import Hummingbird
import Logging
Expand Down
19 changes: 1 addition & 18 deletions Sources/HummingbirdLambda/Request+APIGateway.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2023-2024 the Hummingbird authors
// Copyright (c) 2023-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand All @@ -15,7 +15,6 @@
import AWSLambdaEvents
import AWSLambdaRuntime
import ExtrasBase64
import Foundation
import HTTPTypes
import Hummingbird
import NIOCore
Expand All @@ -32,10 +31,6 @@ protocol APIRequest: LambdaEvent {

extension APIRequest {
public func request(context: LambdaContext) throws -> Request {
func urlPercentEncoded(_ string: String) -> String {
string.addingPercentEncoding(withAllowedCharacters: .urlQueryComponentAllowed) ?? string
}

// construct URI with query parameters
var uri = self.path
if self.queryString.count > 0 {
Expand Down Expand Up @@ -74,10 +69,6 @@ extension APIRequest {
extension Request {
/// Specialization of Lambda.request where `In` is `APIGateway.Request`
init(context: LambdaContext, from: some APIRequest) throws {
func urlPercentEncoded(_ string: String) -> String {
string.addingPercentEncoding(withAllowedCharacters: .urlQueryComponentAllowed) ?? string
}

// construct URI with query parameters
var uri = from.path
if from.queryString.count > 0 {
Expand Down Expand Up @@ -135,11 +126,3 @@ extension HTTPFields {
}
}
}

extension CharacterSet {
nonisolated(unsafe) static var urlQueryComponentAllowed: CharacterSet = {
var cs = CharacterSet.urlQueryAllowed
cs.remove(charactersIn: "&=")
return cs
}()
}
6 changes: 3 additions & 3 deletions Sources/HummingbirdLambda/Response+APIGateway.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2023-2024 the Hummingbird authors
// Copyright (c) 2023-2025 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
Expand Down Expand Up @@ -73,7 +73,7 @@ extension APIResponse {
}

if body == nil {
body = String(_base64Encoding: buffer.readableBytesView)
body = Base64.encodeToString(bytes: buffer.readableBytesView)
isBase64Encoded = true
}

Expand Down Expand Up @@ -131,7 +131,7 @@ extension Response {
}

if body == nil {
body = String(_base64Encoding: buffer.readableBytesView)
body = Base64.encodeToString(bytes: buffer.readableBytesView)
isBase64Encoded = true
}

Expand Down
Loading
Loading