|
@@ -8,7 +8,7 @@ use crate::{
|
|
BuildResult, Result,
|
|
BuildResult, Result,
|
|
};
|
|
};
|
|
use axum::{
|
|
use axum::{
|
|
- body::{Body, HttpBody},
|
|
|
|
|
|
+ body::Body,
|
|
extract::{ws::Message, Extension, WebSocketUpgrade},
|
|
extract::{ws::Message, Extension, WebSocketUpgrade},
|
|
http::{
|
|
http::{
|
|
self,
|
|
self,
|
|
@@ -19,8 +19,7 @@ use axum::{
|
|
routing::{get, get_service},
|
|
routing::{get, get_service},
|
|
Router,
|
|
Router,
|
|
};
|
|
};
|
|
-use axum_extra::TypedHeader;
|
|
|
|
-use axum_server::{service::SendService, tls_rustls::RustlsConfig};
|
|
|
|
|
|
+use axum_server::tls_rustls::RustlsConfig;
|
|
use dioxus_cli_config::CrateConfig;
|
|
use dioxus_cli_config::CrateConfig;
|
|
use dioxus_cli_config::WebHttpsConfig;
|
|
use dioxus_cli_config::WebHttpsConfig;
|
|
|
|
|
|
@@ -299,9 +298,7 @@ async fn setup_router(
|
|
.body(body)
|
|
.body(body)
|
|
.unwrap()
|
|
.unwrap()
|
|
} else {
|
|
} else {
|
|
- response.map(|body| body.try_into().unwrap())
|
|
|
|
- // response.into_body()
|
|
|
|
- // response.map(|body| body.into())
|
|
|
|
|
|
+ response.into_response()
|
|
};
|
|
};
|
|
let headers = response.headers_mut();
|
|
let headers = response.headers_mut();
|
|
headers.insert(
|
|
headers.insert(
|
|
@@ -316,7 +313,7 @@ async fn setup_router(
|
|
.service(ServeDir::new(config.out_dir()));
|
|
.service(ServeDir::new(config.out_dir()));
|
|
|
|
|
|
// Setup websocket
|
|
// Setup websocket
|
|
- let mut router = Router::new().route("/_dioxus/ws", get(ws_handler.into()));
|
|
|
|
|
|
+ let mut router = Router::new().route("/_dioxus/ws", get(ws_handler));
|
|
|
|
|
|
// Setup proxy
|
|
// Setup proxy
|
|
for proxy_config in config.dioxus_config.web.proxy {
|
|
for proxy_config in config.dioxus_config.web.proxy {
|
|
@@ -324,8 +321,8 @@ async fn setup_router(
|
|
}
|
|
}
|
|
|
|
|
|
// Route file service
|
|
// Route file service
|
|
- router = router.fallback(get_service(file_service.into_service()).handle_error(
|
|
|
|
- |error: std::io::Error| async move {
|
|
|
|
|
|
+ router = router.fallback(get_service(file_service).handle_error(
|
|
|
|
+ |error: std::convert::Infallible| async move {
|
|
(
|
|
(
|
|
StatusCode::INTERNAL_SERVER_ERROR,
|
|
StatusCode::INTERNAL_SERVER_ERROR,
|
|
format!("Unhandled internal error: {}", error),
|
|
format!("Unhandled internal error: {}", error),
|
|
@@ -336,7 +333,7 @@ async fn setup_router(
|
|
router = if let Some(base_path) = config.dioxus_config.web.app.base_path.clone() {
|
|
router = if let Some(base_path) = config.dioxus_config.web.app.base_path.clone() {
|
|
let base_path = format!("/{}", base_path.trim_matches('/'));
|
|
let base_path = format!("/{}", base_path.trim_matches('/'));
|
|
Router::new()
|
|
Router::new()
|
|
- .route(&base_path, axum::routing::any_service(router.into()))
|
|
|
|
|
|
+ .route(&base_path, axum::routing::any_service(router))
|
|
.fallback(get(move || {
|
|
.fallback(get(move || {
|
|
let base_path = base_path.clone();
|
|
let base_path = base_path.clone();
|
|
async move { format!("Outside of the base path: {}", base_path) }
|
|
async move { format!("Outside of the base path: {}", base_path) }
|
|
@@ -347,7 +344,7 @@ async fn setup_router(
|
|
|
|
|
|
// Setup routes
|
|
// Setup routes
|
|
router = router
|
|
router = router
|
|
- .route("/_dioxus/hot_reload", get(hot_reload_handler.into()))
|
|
|
|
|
|
+ .route("/_dioxus/hot_reload", get(hot_reload_handler))
|
|
.layer(cors)
|
|
.layer(cors)
|
|
.layer(Extension(ws_reload));
|
|
.layer(Extension(ws_reload));
|
|
|
|
|
|
@@ -418,7 +415,6 @@ fn get_ip() -> Option<String> {
|
|
/// Handle websockets
|
|
/// Handle websockets
|
|
async fn ws_handler(
|
|
async fn ws_handler(
|
|
ws: WebSocketUpgrade,
|
|
ws: WebSocketUpgrade,
|
|
- _: Option<TypedHeader<headers::UserAgent>>,
|
|
|
|
Extension(state): Extension<Arc<WsReloadState>>,
|
|
Extension(state): Extension<Arc<WsReloadState>>,
|
|
) -> impl IntoResponse {
|
|
) -> impl IntoResponse {
|
|
ws.on_upgrade(|mut socket| async move {
|
|
ws.on_upgrade(|mut socket| async move {
|