Skip to content

Commit 286037b

Browse files
Merge pull request #3052 from SwiftPackageIndex/release-crash
Add crash route
2 parents f596615 + 53c703e commit 286037b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Sources/App/routes+documentation.swift

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

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+
}
47+
}
48+
3649
// Stable URLs with reference (real reference or ~)
3750
app.get(":owner", ":repository", ":reference", "documentation", ":archive") {
3851
let route = try await $0.getDocRoute(fragment: .documentation)

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)