Skip to content

Commit

Permalink
Merge pull request #63 from polyphony-chat/gateway
Browse files Browse the repository at this point in the history
add /ping endpoint
  • Loading branch information
bitfl0wer authored Oct 22, 2024
2 parents 2484f88 + 2501d35 commit 21f3b1f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ pub async fn start_api(
)
.nest("/policies", routes::policies::setup_routes())
.nest("/-", routes::health::setup_routes())
.at("/version", routes::version::setup_routes());
.at("/version", routes::version::setup_routes())
.at("/ping", routes::ping::setup_routes());

let v9_api = Route::new()
.at("/ping", routes::ping::setup_routes())
.at("/version", routes::version::setup_routes())
.nest("/api/v9", routes)
.data(db)
Expand Down
1 change: 1 addition & 0 deletions src/api/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod channels;
pub mod guilds;
pub mod health;
pub mod invites;
pub mod ping;
pub mod policies;
pub mod users;
pub mod version;
28 changes: 28 additions & 0 deletions src/api/routes/ping.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use std::env;

use chorus::types::{PingInstance, PingReturn};
use poem::{handler, web::Json, IntoResponse, Route};
use serde::Serialize;

pub fn setup_routes() -> Route {
Route::new().at("/ping", ping)
}

#[handler]
pub async fn ping() -> poem::Result<impl IntoResponse> {
let ping_response = PingReturn {
// TODO: Fill this with configuration values
ping: "pong!".to_string(),
instance: PingInstance {
id: Some(1.into()),
name: "todo".to_string(),
description: None,
image: None,
correspondence_email: None,
correspondence_user_id: None,
front_page: None,
tos_page: None,
},
};
Ok(Json(ping_response))
}

0 comments on commit 21f3b1f

Please sign in to comment.