fn index_static_file_redirect() -> BoxedFilter<(impl Reply,)> {
    warp::get2()
        .and(warp::path::peek())
        .and(warp::fs::file(INDEX_PATH))
        .and_then(|segments: Peek, file: File| {
            // Reject the request if the path starts with /api/
            if let Some(first_segment) = segments.segments().next() {
                if first_segment == API_STRING {
                    //                    return Error::NotFound.reject()
                    return Err(warp::reject::not_found()); // TODO maybe keep this in the Error Type
                }
            }
            Ok(file)
        })
        .boxed()
}
/// If the path does not start with /api, return the index.html, so the app will bootstrap itself
/// regardless of whatever the frontend-specific path is.
If the path does not start with /api, return the index.html, so the app will bootstrap itself
regardless of whatever the frontend-specific path is.
If the path does not start with / api return the index . html so the app will bootstrap itself regardless of whatever the frontend - specific path is .
fn index_static_file_redirect() -> BoxedFilter<(impl Reply,)> {
    warp::get2()
        .and(warp::path::peek())
        .and(warp::fs::file(INDEX_PATH))
        .and_then(|segments: Peek, file: File| {
            // Reject the request if the path starts with /api/
            if let Some(first_segment) = segments.segments().next() {
                if first_segment == API_STRING {
                    //                    return Error::NotFound.reject()
                    return Err(warp::reject::not_found()); // TODO maybe keep this in the Error Type
                }
            }
            Ok(file)
        })
        .boxed()
}
fn index_static_file_redirect ( ) -> BoxedFilter < ( impl Reply , ) > { warp :: get2 ( ) . and ( warp :: path :: peek ( ) ) . and ( warp :: fs :: file ( INDEX_PATH ) ) . and_then ( | segments : Peek , file : File | { // Reject the request if the path starts with /api/ if let Some ( first_segment ) = segments . segments ( ) . next ( ) { if first_segment == API_STRING { //                    return Error::NotFound.reject() return Err ( warp :: reject :: not_found ( ) ) ; // TODO maybe keep this in the Error Type } } Ok ( file ) } ) . boxed ( ) }
If the path does not start with /api, return the index.html, so the app will bootstrap itself
regardless of whatever the frontend-specific path is.
If the path does not start with / api return the index . html so the app will bootstrap itself regardless of whatever the frontend - specific path is .