Skip to content

Commit

Permalink
rename allowable origins case to any (vapor#2397)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored and pull[bot] committed Jun 13, 2020
1 parent 58a9898 commit d63cf58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
@@ -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

0 comments on commit d63cf58

Please sign in to comment.