mirror of
https://github.com/swift-server/swift-openapi-lambda.git
synced 2026-05-03 07:22:26 +00:00
4f2e953097
Change the legal files and the license header in source files according to AWS standards
36 lines
1.3 KiB
Swift
36 lines
1.3 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift OpenAPI Lambda open source project
|
|
//
|
|
// Copyright Swift OpenAPI Lambda project authors
|
|
// Copyright (c) 2023 Amazon.com, Inc. or its affiliates.
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of Swift OpenAPI Lambda project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
import AWSLambdaEvents
|
|
import Foundation
|
|
import HTTPTypes
|
|
|
|
/// Errors returned by the router
|
|
public enum OpenAPILambdaRouterError: Error {
|
|
case noRouteForPath(HTTPRequest.Method, String)
|
|
case noHandlerForPath(String)
|
|
case noRouteForMethod(HTTPRequest.Method)
|
|
}
|
|
|
|
/// A router API
|
|
public protocol OpenAPILambdaRouter: Sendable {
|
|
/// add a route for a given HTTP method and path and associate a handler
|
|
func add(method: HTTPRequest.Method, path: String, handler: @escaping OpenAPIHandler) throws
|
|
|
|
/// Retrieve the handler and path parameter for a given HTTP method and path
|
|
func route(method: HTTPRequest.Method, path: String) throws -> (
|
|
OpenAPIHandler, OpenAPILambdaRequestParameters
|
|
)
|
|
}
|