File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ pub mod user;
97
97
pub mod util;
98
98
pub mod version;
99
99
pub mod email;
100
+ pub mod site_metadata;
100
101
101
102
mod local_upload;
102
103
mod pagination;
@@ -202,6 +203,7 @@ pub fn middleware(app: Arc<App>) -> MiddlewareBuilder {
202
203
api_router. get ( "/summary" , C ( krate:: summary) ) ;
203
204
api_router. put ( "/confirm/:email_token" , C ( user:: confirm_user_email) ) ;
204
205
api_router. put ( "/users/:user_id/resend" , C ( user:: regenerate_token_and_send) ) ;
206
+ api_router. get ( "/site_metadata" , C ( site_metadata:: show_deployed_sha) ) ;
205
207
let api_router = Arc :: new ( R404 ( api_router) ) ;
206
208
207
209
let mut router = RouteBuilder :: new ( ) ;
Original file line number Diff line number Diff line change
1
+ use conduit:: { Request , Response } ;
2
+ use util:: RequestUtils ;
3
+ use util:: errors:: CargoResult ;
4
+
5
+ /// Returns the JSON representation of the current deployed commit sha.
6
+ ///
7
+ /// The sha is contained within the `HEROKU_SLUG_COMMIT` environment variable.
8
+ /// If `HEROKU_SLUG_COMMIT` is not set, returns `"unknown"`.
9
+ pub fn show_deployed_sha ( req : & mut Request ) -> CargoResult < Response > {
10
+ let deployed_sha =
11
+ :: std:: env:: var ( "HEROKU_SLUG_COMMIT" ) . unwrap_or_else ( |_| String :: from ( "unknown" ) ) ;
12
+
13
+ #[ derive( Serialize ) ]
14
+ struct R {
15
+ deployed_sha : String ,
16
+ }
17
+ Ok ( req. json ( & R {
18
+ deployed_sha : deployed_sha,
19
+ } ) )
20
+ }
You can’t perform that action at this time.
0 commit comments