Skip to content

Commit

Permalink
refactor(api): [torrust#143] change fn return type
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Jan 13, 2023
1 parent 02dfe3e commit b7c5144
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/apis/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;
use std::time::Duration;

use axum::extract::{Path, Query, State};
use axum::response::{Json, Response};
use axum::response::{IntoResponse, Json, Response};
use serde::{de, Deserialize, Deserializer};

use super::responses::{
Expand Down Expand Up @@ -33,7 +33,7 @@ pub async fn get_torrent_handler(State(tracker): State<Arc<Tracker>>, Path(info_
match InfoHash::from_str(&info_hash.0) {
Err(_) => invalid_info_hash_param_response(&info_hash.0),
Ok(info_hash) => match get_torrent_info(tracker.clone(), &info_hash).await {
Some(info) => torrent_info_response(info),
Some(info) => torrent_info_response(info).into_response(),
None => torrent_not_known_response(),
},
}
Expand Down
4 changes: 2 additions & 2 deletions src/apis/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ pub fn torrent_list_response(basic_infos: &[BasicInfo]) -> Json<Vec<ListItem>> {
}

#[must_use]
pub fn torrent_info_response(info: Info) -> Response {
Json(Torrent::from(info)).into_response()
pub fn torrent_info_response(info: Info) -> Json<Torrent> {
Json(Torrent::from(info))
}

/// # Panics
Expand Down

0 comments on commit b7c5144

Please sign in to comment.