Skip to content

Commit 53c703e

Browse files
committed
Gate to dev and make the route private
1 parent dcea374 commit 53c703e

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Sources/App/routes+documentation.swift

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ func docRoutes(_ app: Application) throws {
3333
req.redirect(to: SiteURL.relativeURL(for: try await req.getDocRedirect(), fragment: .documentation))
3434
}.excludeFromOpenAPI()
3535

36-
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/3021
37-
// Trigger via
38-
// curl -sL -w "%{http_code}" -o /dev/null http://localhost:8080/crash/1234567890
39-
// NB: length of the archive parameter is relevant, it MUST be >= 10 characters long
40-
app.get("crash", ":archive") { req in
41-
let archive = req.parameters.get("archive")
42-
let _ = ([archive].compacted() + req.parameters.getCatchall()).map { $0.lowercased() }
43-
return ""
36+
if Current.environment() == .development {
37+
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/3021
38+
// Trigger via
39+
// curl -sL -w "%{http_code}" -o /dev/null http://localhost:8080/crash/1234567890
40+
// NB: length of the archive parameter is relevant, it MUST be >= 10 characters long
41+
let crashRoute = Environment.get("CRASH_ROUTE") ?? "crash"
42+
app.get(.init(stringLiteral: crashRoute), ":archive") { req in
43+
let archive = req.parameters.get("archive")
44+
let _ = ([archive].compacted() + req.parameters.getCatchall()).map { $0.lowercased() }
45+
return ""
46+
}
4447
}
4548

4649
// Stable URLs with reference (real reference or ~)

app.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ x-shared: &shared
3737
BUILDER_TOKEN: ${BUILDER_TOKEN}
3838
CHECKOUTS_DIR: ${CHECKOUTS_DIR}
3939
COLLECTION_SIGNING_PRIVATE_KEY: ${COLLECTION_SIGNING_PRIVATE_KEY}
40+
# FIXME: temporary
41+
CRASH_ROUTE: ${CRASH_ROUTE}
4042
DATABASE_ID: ${DATABASE_ID}
4143
DATABASE_HOST: ${DATABASE_HOST}
4244
DATABASE_PORT: ${DATABASE_PORT}

0 commit comments

Comments
 (0)