Skip to content

Commit

Permalink
add /restart_streams route to REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
2smart-dev authored and joaoantoniocardoso committed Feb 27, 2025
1 parent 804e702 commit f4ec894
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/server/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub async fn run(server_address: &str) -> Result<(), std::io::Error> {
.route("/info", web::get().to(pages::info))
.route("/delete_stream", web::delete().to(pages::remove_stream))
.route("/reset_settings", web::post().to(pages::reset_settings))
.route("/restart_streams", web::post().to(pages::restart_streams))
.route("/streams", web::get().to(pages::streams))
.route("/streams", web::post().to(pages::streams_post))
.route("/v4l", web::get().to(pages::v4l))
Expand Down
16 changes: 16 additions & 0 deletions src/lib/server/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,22 @@ pub async fn reset_settings(query: web::Query<ResetSettings>) -> Result<HttpResp
))
}

#[api_v2_operation]
/// Restart streams
pub async fn restart_streams(query: web::Query<ResetSettings>) -> Result<HttpResponse> {
if query.all.unwrap_or_default() {
stream_manager::start_default()
.await
.map_err(|error| Error::Internal(format!("{error:?}")))?;

return Ok(HttpResponse::Ok().finish());
}

Err(Error::Internal(
"Missing argument for restart_streams.".to_string(),
))
}

#[api_v2_operation]
/// Provide a list of all streams configured
pub async fn streams() -> Result<HttpResponse> {
Expand Down

0 comments on commit f4ec894

Please sign in to comment.