mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 16:05:58 +00:00
remove rust embed in dev mode
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
use crate::job_helpers_ee::get_workspace_s3_resource;
|
||||
use crate::{
|
||||
args::WebhookArgs,
|
||||
auth::{AuthCache, OptTokened},
|
||||
db::{ApiAuthed, DB},
|
||||
jobs::{
|
||||
run_flow_by_path_inner, run_script_by_path_inner, run_wait_result_flow_by_path_internal,
|
||||
run_wait_result_script_by_path_internal, RunJobQuery,
|
||||
},
|
||||
users::{fetch_api_authed, AuthCache, OptTokened},
|
||||
users::fetch_api_authed,
|
||||
};
|
||||
use axum::{
|
||||
extract::{Path, Query},
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
* LICENSE-AGPL for a copy of the license.
|
||||
*/
|
||||
|
||||
use axum::{
|
||||
body::Body,
|
||||
extract::OriginalUri,
|
||||
http::{header, Response},
|
||||
response::IntoResponse,
|
||||
};
|
||||
use axum::{body::Body, extract::OriginalUri, http::Response, response::IntoResponse};
|
||||
|
||||
#[cfg(feature = "static_frontend")]
|
||||
use axum::http::header;
|
||||
|
||||
use hyper::Uri;
|
||||
#[cfg(feature = "static_frontend")]
|
||||
use mime_guess::mime;
|
||||
#[cfg(feature = "static_frontend")]
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
// static_handler is a handler that serves static files from the
|
||||
@@ -22,6 +22,7 @@ pub async fn static_handler(OriginalUri(original_uri): OriginalUri) -> StaticFil
|
||||
StaticFile(original_uri)
|
||||
}
|
||||
|
||||
#[cfg(feature = "static_frontend")]
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "${FRONTEND_BUILD_DIR:-../../frontend/build/}"]
|
||||
struct Asset;
|
||||
@@ -34,6 +35,7 @@ impl IntoResponse for StaticFile {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "static_frontend")]
|
||||
const TWO_HUNDRED: &str = "200.html";
|
||||
|
||||
fn serve_path(path: &str) -> Response<Body> {
|
||||
@@ -41,6 +43,7 @@ fn serve_path(path: &str) -> Response<Body> {
|
||||
return Response::builder().status(404).body(Body::empty()).unwrap();
|
||||
}
|
||||
|
||||
#[cfg(feature = "static_frontend")]
|
||||
match Asset::get(path) {
|
||||
Some(content) => {
|
||||
let body = Body::from(content.data);
|
||||
@@ -68,4 +71,9 @@ fn serve_path(path: &str) -> Response<Body> {
|
||||
}
|
||||
None => serve_path(TWO_HUNDRED),
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "static_frontend"))]
|
||||
{
|
||||
Response::builder().status(404).body(Body::empty()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user