mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
fix a few CLI errors
This commit is contained in:
parent
e745212157
commit
194d90e66f
6 changed files with 15 additions and 14 deletions
|
@ -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.into()))
|
||||
.route(&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) }
|
||||
|
|
|
@ -4,12 +4,13 @@ use dioxus_cli_config::WebProxyConfig;
|
|||
use anyhow::Context;
|
||||
use axum::{http::StatusCode, routing::any, Router};
|
||||
use hyper::{Request, Response, Uri};
|
||||
use hyper::client::legacy::Client;
|
||||
|
||||
use axum::body::Body as MyBody;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct ProxyClient {
|
||||
inner: hyper::Client<hyper_rustls::HttpsConnector<hyper::client::HttpConnector>>,
|
||||
inner: Client<hyper_rustls::HttpsConnector<Client::HttpConnector>>,
|
||||
url: Uri,
|
||||
}
|
||||
|
||||
|
@ -22,7 +23,7 @@ impl ProxyClient {
|
|||
.enable_http1()
|
||||
.build();
|
||||
Self {
|
||||
inner: hyper::Client::builder().build(https),
|
||||
inner: Client::builder().build(https),
|
||||
url,
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +99,7 @@ mod test {
|
|||
use super::*;
|
||||
|
||||
use axum::{extract::Path, Router};
|
||||
use axum_server::Server;
|
||||
|
||||
fn setup_servers(
|
||||
mut config: WebProxyConfig,
|
||||
|
@ -110,13 +112,13 @@ mod test {
|
|||
"/*path",
|
||||
any(|path: Path<String>| async move { format!("backend: {}", path.0) }),
|
||||
);
|
||||
let backend_server = axum::Server::bind(&"127.0.0.1:0".parse().unwrap())
|
||||
let backend_server = Server::bind(&"127.0.0.1:0".parse().unwrap())
|
||||
.serve(backend_router.into_make_service());
|
||||
let backend_addr = backend_server.local_addr();
|
||||
let backend_handle = tokio::spawn(async move { backend_server.await.unwrap() });
|
||||
config.backend = format!("http://{}{}", backend_addr, config.backend);
|
||||
let router = super::add_proxy(Router::new(), &config);
|
||||
let server = axum::Server::bind(&"127.0.0.1:0".parse().unwrap())
|
||||
let server = Server::bind("127.0.0.1:0".parse().unwrap())
|
||||
.serve(router.unwrap().into_make_service());
|
||||
let server_addr = server.local_addr();
|
||||
let server_handle = tokio::spawn(async move { server.await.unwrap() });
|
||||
|
@ -132,8 +134,8 @@ mod test {
|
|||
// So in day to day usage, use `http://localhost:8000/api` instead!
|
||||
backend: path,
|
||||
};
|
||||
let (backend_handle, server_handle, server_addr) = setup_servers(config);
|
||||
let resp = hyper::Client::new()
|
||||
let (backend_handle, server_handle, server_addr) = setup_servers(config).await;
|
||||
let resp = Client::new()
|
||||
.get(format!("http://{}/api", server_addr).parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -145,7 +147,7 @@ mod test {
|
|||
"backend: /api"
|
||||
);
|
||||
|
||||
let resp = hyper::Client::new()
|
||||
let resp = Client::new()
|
||||
.get(format!("http://{}/api/", server_addr).parse().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -157,7 +159,7 @@ mod test {
|
|||
"backend: /api/"
|
||||
);
|
||||
|
||||
let resp = hyper::Client::new()
|
||||
let resp = Client::new()
|
||||
.get(
|
||||
format!("http://{}/api/subpath", server_addr)
|
||||
.parse()
|
||||
|
|
|
@ -49,7 +49,7 @@ fn main() {
|
|||
// build our application with some routes
|
||||
let app = Router::new()
|
||||
// Server side render the application, serve static assets, and register server functions
|
||||
.serve_dioxus_application("", ServeConfig::builder().build(), || {
|
||||
.serve_dioxus_application(ServeConfig::builder().build(), || {
|
||||
VirtualDom::new(app)
|
||||
})
|
||||
.layer(
|
||||
|
|
|
@ -12,8 +12,8 @@ async fn main() {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let _ = PostServerData::register_explicit();
|
||||
let _ = GetServerData::register_explicit();
|
||||
let _ = register_explicit::<PostServerData>();
|
||||
let _ = register_explicit::<GetServerData>();
|
||||
|
||||
axum::serve(
|
||||
listener,
|
||||
|
|
|
@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
|
|||
#[cfg(feature = "server")]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
pre_cache_static_routes_with_props(
|
||||
pre_cache_static_routes(
|
||||
&ServeConfig::new_with_router(
|
||||
dioxus_fullstack::router::FullstackRouterConfig::<Route>::default(),
|
||||
)
|
||||
|
|
|
@ -23,7 +23,6 @@ server_fn_macro = "^0.6.5"
|
|||
proc-macro = true
|
||||
|
||||
[features]
|
||||
actix = ["server_fn_macro/actix"]
|
||||
axum = ["server_fn_macro/axum"]
|
||||
nightly = ["server_fn_macro/nightly"]
|
||||
server = ["server_fn_macro/ssr"]
|
||||
|
|
Loading…
Reference in a new issue