@@ -62,7 +62,7 @@ struct FileExplorerPlugin {
6262
6363#[ async_trait]
6464impl Plugin for FileExplorerPlugin {
65- async fn call ( & self , parts : Parts , body : Bytes ) -> Result < Response < Full < Bytes > > , PluginError > {
65+ fn call ( & self , parts : Parts , body : Bytes ) -> Result < Response < Full < Bytes > > , PluginError > {
6666 self . rt
6767 . block_on ( async move { self . handle ( parts, body) . await } )
6868 }
@@ -84,37 +84,38 @@ impl FileExplorerPlugin {
8484 parts : Parts ,
8585 body : Bytes ,
8686 ) -> Result < Response < Full < Bytes > > , PluginError > {
87- tracing:: info!( "Handling request: {:?}" , parts) ;
88-
89- if parts. uri . path ( ) . starts_with ( "/api/v1" ) {
90- self . handle_api ( parts, body) . await
91- } else {
92- let path = parts. uri . path ( ) ;
93- let path = path. strip_prefix ( '/' ) . unwrap_or ( path) ;
94-
95- if let Some ( file) = Assets :: get ( path) {
96- let content_type = mime_guess:: from_path ( path) . first_or_octet_stream ( ) ;
97- let content_type = HeaderValue :: from_str ( content_type. as_ref ( ) ) . unwrap ( ) ;
98- let body = Full :: new ( Bytes :: from ( file. data . to_vec ( ) ) ) ;
99- let mut response = Response :: new ( body) ;
100- let mut headers = response. headers ( ) . clone ( ) ;
101-
102- headers. append ( CONTENT_TYPE , content_type) ;
103- * response. headers_mut ( ) = headers;
104-
105- return Ok ( response) ;
106- }
107-
108- let index = Assets :: get ( "index.html" ) . unwrap ( ) ;
109- let body = Full :: new ( Bytes :: from ( index. data . to_vec ( ) ) ) ;
110- let mut response = Response :: new ( body) ;
111- let mut headers = response. headers ( ) . clone ( ) ;
112-
113- headers. append ( CONTENT_TYPE , "text/html" . try_into ( ) . unwrap ( ) ) ;
114- * response. headers_mut ( ) = headers;
115-
116- Ok ( response)
117- }
87+ Ok ( Response :: new ( Full :: new ( Bytes :: from ( "Unsupported method" ) ) ) )
88+ // tracing::info!("Handling request: {:?}", parts);
89+
90+ // if parts.uri.path().starts_with("/api/v1") {
91+ // self.handle_api(parts, body).await
92+ // } else {
93+ // let path = parts.uri.path();
94+ // let path = path.strip_prefix('/').unwrap_or(path);
95+
96+ // if let Some(file) = Assets::get(path) {
97+ // let content_type = mime_guess::from_path(path).first_or_octet_stream();
98+ // let content_type = HeaderValue::from_str(content_type.as_ref()).unwrap();
99+ // let body = Full::new(Bytes::from(file.data.to_vec()));
100+ // let mut response = Response::new(body);
101+ // let mut headers = response.headers().clone();
102+
103+ // headers.append(CONTENT_TYPE, content_type);
104+ // *response.headers_mut() = headers;
105+
106+ // return Ok(response);
107+ // }
108+
109+ // let index = Assets::get("index.html").unwrap();
110+ // let body = Full::new(Bytes::from(index.data.to_vec()));
111+ // let mut response = Response::new(body);
112+ // let mut headers = response.headers().clone();
113+
114+ // headers.append(CONTENT_TYPE, "text/html".try_into().unwrap());
115+ // *response.headers_mut() = headers;
116+
117+ // Ok(response)
118+ // }
118119 }
119120
120121 async fn handle_api (
0 commit comments