1111// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212// See the License for the specific language governing permissions and
1313// limitations under the License.
14-
1514use axum:: {
1615 extract:: Path ,
1716 http:: { header, Response , StatusCode } ,
@@ -21,7 +20,7 @@ use mime_guess::from_path;
2120use rust_embed:: RustEmbed ;
2221
2322#[ derive( RustEmbed ) ]
24- #[ folder = "ui/dist/cb-admin/" ]
23+ #[ folder = "ui/dist/cb-admin/" ] // Ruta relativa al Cargo.toml
2524pub struct EmbeddedAssets ;
2625
2726
@@ -30,15 +29,6 @@ pub async fn embedded_ui_handler(Path(path): Path<String>) -> impl IntoResponse
3029
3130 let clean_path = path. trim_start_matches ( '/' ) ;
3231
33- /// Determines the appropriate asset path to serve based on the provided `clean_path`.
34- ///
35- /// - If `clean_path` is empty, defaults to `"index.html"`.
36- /// - If an asset exists for `clean_path`, uses it directly.
37- /// - Otherwise, checks if an asset exists for `"{clean_path}/index.html"` and uses it if available.
38- /// - If none of the above, falls back to using `clean_path` as is.
39- ///
40- /// This logic ensures that directory requests are resolved to their `index.html`
41- /// and that only existing embedded assets are served.
4232 let resolved_path = if clean_path. is_empty ( ) {
4333 "index.html" . to_string ( )
4434 } else if EmbeddedAssets :: get ( clean_path) . is_some ( ) {
@@ -48,18 +38,12 @@ pub async fn embedded_ui_handler(Path(path): Path<String>) -> impl IntoResponse
4838 if EmbeddedAssets :: get ( & with_index) . is_some ( ) {
4939 with_index
5040 } else {
51- clean_path. to_string ( )
41+ clean_path. to_string ( ) // Intento final (puede fallar)
5242 }
5343 } ;
5444
5545 match EmbeddedAssets :: get ( & resolved_path) {
5646 Some ( content) => {
57- /// Determines the MIME type of the file at the given `resolved_path`.
58- /// If the MIME type cannot be determined, defaults to `application/octet-stream`.
59- ///
60- /// # Returns
61- ///
62- /// A [`mime::Mime`] representing the file's MIME type.
6347 let mime = from_path ( & resolved_path) . first_or_octet_stream ( ) ;
6448 Response :: builder ( )
6549 . header ( header:: CONTENT_TYPE , mime. as_ref ( ) )
0 commit comments