let fallback_service = ServeDir::new(&assets)
.not_found_service(handler_404.into_service());
let app = Router::new()
// your routes
.fallback_service(fallback_service)
If you need your state inside your 404_handler try this instead.
let fallback_service = ServeDir::new(&assets)
.not_found_service(Handler::with_state(handler_404, state.clone()));