From 4f55dd22a71db88c3f53d1efa67ce877e0357f76 Mon Sep 17 00:00:00 2001 From: Roland Lariotte Date: Fri, 2 Jun 2023 16:20:50 +0200 Subject: [PATCH] Update Heroku documentation to deploy Postgress following Vapor 4.77 update (#814) --- docs/deploy/heroku.md | 11 ++++++++--- docs/deploy/heroku.nl.md | 11 ++++++++--- docs/deploy/heroku.zh.md | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/docs/deploy/heroku.md b/docs/deploy/heroku.md index 2b9b4a9c..664716d2 100644 --- a/docs/deploy/heroku.md +++ b/docs/deploy/heroku.md @@ -200,9 +200,14 @@ The Heroku Postgres addon [requires](https://devcenter.heroku.com/changelog-item The following snippet shows how to achieve both: ```swift -if let databaseURL = Environment.get("DATABASE_URL"), var postgresConfig = PostgresConfiguration(url: databaseURL) { - postgresConfig.tlsConfiguration = .makeClientConfiguration() - postgresConfig.tlsConfiguration?.certificateVerification = .none +if let databaseURL = Environment.get("DATABASE_URL") { + var tlsConfig: TLSConfiguration = .makeClientConfiguration() + tlsConfig.certificateVerification = .none + let nioSSLContext = try NIOSSLContext(configuration: tlsConfig) + + var postgresConfig = try SQLPostgresConfiguration(url: databaseURL) + postgresConfig.coreConfiguration.tls = .require(nioSSLContext) + app.databases.use(.postgres(configuration: postgresConfig), as: .psql) } else { // ... diff --git a/docs/deploy/heroku.nl.md b/docs/deploy/heroku.nl.md index 76a81a66..b145c484 100644 --- a/docs/deploy/heroku.nl.md +++ b/docs/deploy/heroku.nl.md @@ -199,9 +199,14 @@ De Heroku Postgres addon [vereist](https://devcenter.heroku.com/changelog-items/ Het volgende fragment laat zien hoe beide bereikt kunnen worden: ```swift -if let databaseURL = Environment.get("DATABASE_URL"), var postgresConfig = PostgresConfiguration(url: databaseURL) { - postgresConfig.tlsConfiguration = .makeClientConfiguration() - postgresConfig.tlsConfiguration?.certificateVerification = .none +if let databaseURL = Environment.get("DATABASE_URL") { + var tlsConfig: TLSConfiguration = .makeClientConfiguration() + tlsConfig.certificateVerification = .none + let nioSSLContext = try NIOSSLContext(configuration: tlsConfig) + + var postgresConfig = try SQLPostgresConfiguration(url: databaseURL) + postgresConfig.coreConfiguration.tls = .require(nioSSLContext) + app.databases.use(.postgres(configuration: postgresConfig), as: .psql) } else { // ... diff --git a/docs/deploy/heroku.zh.md b/docs/deploy/heroku.zh.md index 2c382214..5fac31d8 100644 --- a/docs/deploy/heroku.zh.md +++ b/docs/deploy/heroku.zh.md @@ -198,9 +198,14 @@ DATABASE_URL: postgres://cybntsgadydqzm:2d9dc7f6d964f4750da1518ad71hag2ba729cd45 ```swift if let databaseURL = Environment.get("DATABASE_URL") { - app.databases.use(try .postgres( - url: databaseURL - ), as: .psql) + var tlsConfig: TLSConfiguration = .makeClientConfiguration() + tlsConfig.certificateVerification = .none + let nioSSLContext = try NIOSSLContext(configuration: tlsConfig) + + var postgresConfig = try SQLPostgresConfiguration(url: databaseURL) + postgresConfig.coreConfiguration.tls = .require(nioSSLContext) + + app.databases.use(.postgres(configuration: postgresConfig), as: .psql) } else { // ... }