Browse Source

clean up workflow, fix some more axum stuff

Jonathan Kelley 1 year ago
parent
commit
2763adb2d3
2 changed files with 7 additions and 47 deletions
  1. 0 39
      .github/workflows/main.yml
  2. 7 8
      packages/cli/src/server/web/mod.rs

+ 0 - 39
.github/workflows/main.yml

@@ -112,44 +112,6 @@ jobs:
           save-if: ${{ github.ref == 'refs/heads/master' }}
       - run: cargo clippy --workspace --examples --tests --all-features --all-targets -- -D warnings
 
-  # We removed most unsafe that we can, and using nightly doubles our cache size
-  # miri:
-  #   if: github.event.pull_request.draft == false
-  #   name: Miri
-  #   runs-on: ubuntu-latest
-  #   env:
-  #     CARGO_UNSTABLE_SPARSE_REGISTRY: 'true'
-  #     RUSTFLAGS: -Dwarnings
-  #     RUST_BACKTRACE: 1
-  #     MIRIFLAGS: -Zmiri-tag-gc=1
-  #     # Change to specific Rust release to pin
-  #     rust_stable: stable
-  #     rust_nightly: nightly-2023-11-16
-  #     rust_clippy: 1.70.0
-
-  #   steps:
-  #     - uses: actions/checkout@v4
-  #     - uses: ilammy/setup-nasm@v1
-  #     - name: Install Rust ${{ env.rust_nightly }}
-  #       uses: dtolnay/rust-toolchain@master
-  #       with:
-  #         toolchain: ${{ env.rust_nightly }}
-  #         components: miri
-  #     - uses: Swatinem/rust-cache@v2
-  #       with:
-  #         cache-all-crates: "true"
-  #         save-if: ${{ github.ref == 'refs/heads/master' }}
-  #     - name: miri
-  #       # Many of tests in tokio/tests and doctests use #[tokio::test] or
-  #       # #[tokio::main] that calls epoll_create1 that Miri does not support.
-  #       # run: cargo miri test --features full --lib --no-fail-fast
-  #       run: |
-  #         cargo miri test --package dioxus-core -- --exact --nocapture
-  #         cargo miri test --package dioxus-native-core --test miri_native  -- --exact --nocapture
-  #       env:
-  #         MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields
-  #         PROPTEST_CASES: 10
-
   playwright:
     if: github.event.pull_request.draft == false
     name: Playwright Tests
@@ -200,7 +162,6 @@ jobs:
           path: playwright-report/
           retention-days: 30
 
-
   matrix_test:
     runs-on: ${{ matrix.platform.os }}
     if: github.event.pull_request.draft == false

+ 7 - 8
packages/cli/src/server/web/mod.rs

@@ -20,7 +20,7 @@ use axum::{
     Router,
 };
 use axum_extra::TypedHeader;
-use axum_server::tls_rustls::RustlsConfig;
+use axum_server::{service::SendService, tls_rustls::RustlsConfig};
 use dioxus_cli_config::CrateConfig;
 use dioxus_cli_config::WebHttpsConfig;
 
@@ -316,7 +316,7 @@ async fn setup_router(
         .service(ServeDir::new(config.out_dir()));
 
     // Setup websocket
-    let mut router = Router::new().route("/_dioxus/ws", get(ws_handler));
+    let mut router = Router::new().route("/_dioxus/ws", get(ws_handler.into()));
 
     // Setup proxy
     for proxy_config in config.dioxus_config.web.proxy {
@@ -324,7 +324,7 @@ async fn setup_router(
     }
 
     // Route file service
-    router = router.fallback(get_service(file_service).handle_error(
+    router = router.fallback(get_service(file_service.into_service()).handle_error(
         |error: std::io::Error| async move {
             (
                 StatusCode::INTERNAL_SERVER_ERROR,
@@ -336,7 +336,7 @@ async fn setup_router(
     router = if let Some(base_path) = config.dioxus_config.web.app.base_path.clone() {
         let base_path = format!("/{}", base_path.trim_matches('/'));
         Router::new()
-            .nest(&base_path, axum::routing::any_service(router))
+            .nest(&base_path, axum::routing::any_service(router.into()))
             .fallback(get(move || {
                 let base_path = base_path.clone();
                 async move { format!("Outside of the base path: {}", base_path) }
@@ -347,7 +347,7 @@ async fn setup_router(
 
     // Setup routes
     router = router
-        .route("/_dioxus/hot_reload", get(hot_reload_handler))
+        .route("/_dioxus/hot_reload", get(hot_reload_handler.into()))
         .layer(cors)
         .layer(Extension(ws_reload));
 
@@ -389,9 +389,8 @@ async fn start_server(
                 .await?
         }
         None => {
-            axum::Server::bind(&addr)
-                .serve(router.into_make_service())
-                .await?
+            let listener = tokio::net::TcpListener::bind(&addr).await?;
+            axum::serve(listener, router.into_make_service()).await?
         }
     }