Skip to content

Commit

Permalink
feat(info): add an info endpoint (#301)
Browse files Browse the repository at this point in the history
* feat(info): add an info endpoint

Co-authored-by: Leo McArdle <[email protected]>
  • Loading branch information
fiji-flo and LeoMcA authored Jul 24, 2023
1 parent c90d377 commit 9614323
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/api_v1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::api::ai::{ask, explain, explain_feedback, quota};
use crate::api::info::information;
use crate::api::newsletter::{
is_subscribed, subscribe_anonymous_handler, subscribe_handler, unsubscribe_handler,
};
Expand All @@ -16,6 +17,7 @@ pub fn api_v1_service() -> impl HttpServiceFactory {
// limit request payload size to 1MB
.limit(1_048_576);
web::scope("/api/v1")
.service(web::resource("/info").route(web::get().to(information)))
.service(
web::scope("/plus")
.service(
Expand Down
15 changes: 15 additions & 0 deletions src/api/info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use actix_web::HttpResponse;
use serde::Serialize;

#[derive(Serialize)]
struct Info {
version: &'static str,
}

const INFO: Info = Info {
version: env!("CARGO_PKG_VERSION"),
};

pub async fn information() -> HttpResponse {
HttpResponse::Ok().json(INFO)
}
1 change: 1 addition & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod elastic;
pub mod error;
pub mod fxa_webhook;
pub mod healthz;
pub mod info;
pub mod newsletter;
pub mod ping;
pub mod play;
Expand Down

0 comments on commit 9614323

Please sign in to comment.