mirror of https://github.com/vapor/docs.git
Update Heroku documentation to deploy Postgress following Vapor 4.77 update (#814)
This commit is contained in:
parent
3512ad7397
commit
4f55dd22a7
|
|
@ -200,9 +200,14 @@ The Heroku Postgres addon [requires](https://devcenter.heroku.com/changelog-item
|
||||||
The following snippet shows how to achieve both:
|
The following snippet shows how to achieve both:
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
if let databaseURL = Environment.get("DATABASE_URL"), var postgresConfig = PostgresConfiguration(url: databaseURL) {
|
if let databaseURL = Environment.get("DATABASE_URL") {
|
||||||
postgresConfig.tlsConfiguration = .makeClientConfiguration()
|
var tlsConfig: TLSConfiguration = .makeClientConfiguration()
|
||||||
postgresConfig.tlsConfiguration?.certificateVerification = .none
|
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)
|
app.databases.use(.postgres(configuration: postgresConfig), as: .psql)
|
||||||
} else {
|
} else {
|
||||||
// ...
|
// ...
|
||||||
|
|
|
||||||
|
|
@ -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:
|
Het volgende fragment laat zien hoe beide bereikt kunnen worden:
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
if let databaseURL = Environment.get("DATABASE_URL"), var postgresConfig = PostgresConfiguration(url: databaseURL) {
|
if let databaseURL = Environment.get("DATABASE_URL") {
|
||||||
postgresConfig.tlsConfiguration = .makeClientConfiguration()
|
var tlsConfig: TLSConfiguration = .makeClientConfiguration()
|
||||||
postgresConfig.tlsConfiguration?.certificateVerification = .none
|
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)
|
app.databases.use(.postgres(configuration: postgresConfig), as: .psql)
|
||||||
} else {
|
} else {
|
||||||
// ...
|
// ...
|
||||||
|
|
|
||||||
|
|
@ -198,9 +198,14 @@ DATABASE_URL: postgres://cybntsgadydqzm:2d9dc7f6d964f4750da1518ad71hag2ba729cd45
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
if let databaseURL = Environment.get("DATABASE_URL") {
|
if let databaseURL = Environment.get("DATABASE_URL") {
|
||||||
app.databases.use(try .postgres(
|
var tlsConfig: TLSConfiguration = .makeClientConfiguration()
|
||||||
url: databaseURL
|
tlsConfig.certificateVerification = .none
|
||||||
), as: .psql)
|
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 {
|
} else {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue