Skip to content

Commit 9a28438

Browse files
committed
Auto merge of #3994 - Turbo87:read-only, r=locks
site_metadata: Expose `read_only` field As discussed on Thursday, it would be nice to display on the frontend that we're currently in read-only mode during e.g. database updates. This PR adds a `read_only` field to the `/api/v1/site_metadata` endpoint response.
2 parents 956ed91 + 606f918 commit 9a28438

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/controllers/site_metadata.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ use super::prelude::*;
55
/// The sha is contained within the `HEROKU_SLUG_COMMIT` environment variable.
66
/// If `HEROKU_SLUG_COMMIT` is not set, returns `"unknown"`.
77
pub fn show_deployed_sha(req: &mut dyn RequestExt) -> EndpointResult {
8+
let config = &req.app().config;
9+
let read_only = config.db.are_all_read_only();
10+
811
let deployed_sha =
912
dotenv::var("HEROKU_SLUG_COMMIT").unwrap_or_else(|_| String::from("unknown"));
1013

1114
Ok(req.json(&json!({
1215
"deployed_sha": &deployed_sha[..],
1316
"commit": &deployed_sha[..],
17+
"read_only": read_only,
1418
})))
1519
}

0 commit comments

Comments
 (0)