Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename CORSMiddleware allowable origins case #2397

Merged
merged 1 commit into from Jun 13, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,6 @@
extension CORSMiddleware.AllowOriginSetting {
@available(*, deprecated, renamed: "any")
public static func whitelist(_ origins: [String]) -> Self {
.any(origins)
}
}
8 changes: 4 additions & 4 deletions Sources/Vapor/Middleware/CORSMiddleware.swift
Expand Up @@ -9,7 +9,7 @@ public final class CORSMiddleware: Middleware {
/// - none: Disallows any origin.
/// - originBased: Uses value of the origin header in the request.
/// - all: Uses wildcard to allow any origin.
/// - whitelist: Uses a whitelist of allowable origins.
/// - any: A list of allowable origins.
/// - custom: Uses custom string provided as an associated value.
public enum AllowOriginSetting {
/// Disallow any origin.
Expand All @@ -21,8 +21,8 @@ public final class CORSMiddleware: Middleware {
/// Uses wildcard to allow any origin.
case all

// Uses a whitelist of allowable origins.
case whitelist([String])
/// A list of allowable origins.
case any([String])

/// Uses custom string provided as an associated value.
case custom(String)
Expand All @@ -36,7 +36,7 @@ public final class CORSMiddleware: Middleware {
case .none: return ""
case .originBased: return req.headers[.origin].first ?? ""
case .all: return "*"
case .whitelist(let origins):
case .any(let origins):
guard let origin = req.headers[.origin].first else {
return ""
}
Expand Down