follow up to serveconfig (#4820)
* remove latent dbg! * cleanup serveconfig
This commit is contained in:
1 parent
7408a33be7
commit
306639ee9f
5 files changed
+120
-119
No files matched your search
@@ -120,11 +120,9 @@ where
|
||||
S: Send + Sync + Clone + 'static,
|
||||
{
|
||||
fn serve_static_assets(self) -> Self {
|
||||
let public_path = public_path();
|
||||
|
||||
if !public_path.exists() {
|
||||
let Some(public_path) = public_path() else {
|
||||
return self;
|
||||
}
|
||||
};
|
||||
|
||||
// Serve all files in public folder except index.html
|
||||
serve_dir_cached(self, &public_path, &public_path)
|
||||
@@ -284,11 +282,9 @@ impl RenderHandleState {
|
||||
/// axum::serve(listener, router).await.unwrap();
|
||||
/// }
|
||||
/// ```
|
||||
pub async fn render_handler(State(mut state): State<Self>, request: Request<Body>) -> Response {
|
||||
pub async fn render_handler(State(state): State<Self>, request: Request<Body>) -> Response {
|
||||
let (parts, _) = request.into_parts();
|
||||
|
||||
state.config.resolve_index();
|
||||
|
||||
let response = state
|
||||
.renderers
|
||||
.clone()
|
||||
@@ -350,17 +346,19 @@ impl RenderHandleState {
|
||||
}
|
||||
|
||||
/// Get the path to the public assets directory to serve static files from
|
||||
pub(crate) fn public_path() -> PathBuf {
|
||||
pub(crate) fn public_path() -> Option<PathBuf> {
|
||||
if let Ok(path) = std::env::var("DIOXUS_PUBLIC_PATH") {
|
||||
return PathBuf::from(path);
|
||||
return Some(PathBuf::from(path));
|
||||
}
|
||||
|
||||
// The CLI always bundles static assets into the exe/public directory
|
||||
std::env::current_exe()
|
||||
.expect("Failed to get current executable path")
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("public")
|
||||
Some(
|
||||
std::env::current_exe()
|
||||
.ok()?
|
||||
.parent()
|
||||
.unwrap()
|
||||
.join("public"),
|
||||
)
|
||||
}
|
||||
|
||||
fn serve_dir_cached<S>(mut router: Router<S>, public_path: &Path, directory: &Path) -> Router<S>
|
||||
|
||||
Reference in new issue
Block a user