@@ -7,16 +7,15 @@ use axum::response::{IntoResponse, Json, Response};
77use serde:: { de, Deserialize , Deserializer } ;
88
99use super :: responses:: {
10- failed_to_reload_whitelist_response, failed_to_remove_torrent_from_whitelist_response, failed_to_whitelist_torrent_response,
11- invalid_info_hash_param_response, ok_response, torrent_info_response, torrent_list_response, torrent_not_known_response,
10+ invalid_info_hash_param_response, torrent_info_response, torrent_list_response, torrent_not_known_response,
1211} ;
1312use crate :: apis:: resources:: torrent:: ListItem ;
1413use crate :: protocol:: info_hash:: InfoHash ;
1514use crate :: tracker:: services:: torrent:: { get_torrent_info, get_torrents, Pagination } ;
1615use crate :: tracker:: Tracker ;
1716
1817#[ derive( Deserialize ) ]
19- pub struct InfoHashParam ( String ) ;
18+ pub struct InfoHashParam ( pub String ) ;
2019
2120pub async fn get_torrent_handler ( State ( tracker) : State < Arc < Tracker > > , Path ( info_hash) : Path < InfoHashParam > ) -> Response {
2221 match InfoHash :: from_str ( & info_hash. 0 ) {
@@ -48,39 +47,6 @@ pub async fn get_torrents_handler(
4847 )
4948}
5049
51- pub async fn add_torrent_to_whitelist_handler (
52- State ( tracker) : State < Arc < Tracker > > ,
53- Path ( info_hash) : Path < InfoHashParam > ,
54- ) -> Response {
55- match InfoHash :: from_str ( & info_hash. 0 ) {
56- Err ( _) => invalid_info_hash_param_response ( & info_hash. 0 ) ,
57- Ok ( info_hash) => match tracker. add_torrent_to_whitelist ( & info_hash) . await {
58- Ok ( _) => ok_response ( ) ,
59- Err ( e) => failed_to_whitelist_torrent_response ( e) ,
60- } ,
61- }
62- }
63-
64- pub async fn remove_torrent_from_whitelist_handler (
65- State ( tracker) : State < Arc < Tracker > > ,
66- Path ( info_hash) : Path < InfoHashParam > ,
67- ) -> Response {
68- match InfoHash :: from_str ( & info_hash. 0 ) {
69- Err ( _) => invalid_info_hash_param_response ( & info_hash. 0 ) ,
70- Ok ( info_hash) => match tracker. remove_torrent_from_whitelist ( & info_hash) . await {
71- Ok ( _) => ok_response ( ) ,
72- Err ( e) => failed_to_remove_torrent_from_whitelist_response ( e) ,
73- } ,
74- }
75- }
76-
77- pub async fn reload_whitelist_handler ( State ( tracker) : State < Arc < Tracker > > ) -> Response {
78- match tracker. load_whitelist_from_database ( ) . await {
79- Ok ( _) => ok_response ( ) ,
80- Err ( e) => failed_to_reload_whitelist_response ( e) ,
81- }
82- }
83-
8450/// Serde deserialization decorator to map empty Strings to None,
8551fn empty_string_as_none < ' de , D , T > ( de : D ) -> Result < Option < T > , D :: Error >
8652where
0 commit comments