-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from Devolutions/WAYK-2567
WAYK-2567: Add endpoint to get logs (GET /diagnostics/logs)
- Loading branch information
Showing
5 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::config::Config; | ||
use crate::http::guards::access::{AccessGuard, JetTokenType}; | ||
use crate::http::HttpErrorStatus; | ||
use jet_proto::token::JetAccessScope; | ||
use saphir::prelude::*; | ||
use std::sync::Arc; | ||
|
||
pub struct DiagnosticsController { | ||
config: Arc<Config>, | ||
} | ||
|
||
impl DiagnosticsController { | ||
pub fn new(config: Arc<Config>) -> Self { | ||
DiagnosticsController { config } | ||
} | ||
} | ||
|
||
#[controller(name = "diagnostics")] | ||
impl DiagnosticsController { | ||
#[get("/logs")] | ||
#[guard( | ||
AccessGuard, | ||
init_expr = r#"JetTokenType::Scope(JetAccessScope::GatewayDiagnosticsRead)"# | ||
)] | ||
async fn get_logs(&self) -> Result<File, HttpErrorStatus> { | ||
let log_file_path = self | ||
.config | ||
.log_file | ||
.as_ref() | ||
.ok_or_else(|| HttpErrorStatus::not_found("Log file is not configured"))?; | ||
File::open(log_file_path).await.map_err(HttpErrorStatus::internal) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod diagnostics; | ||
pub mod health; | ||
pub mod http_bridge; | ||
pub mod jet; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters