mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
app: server uncompressed WASM to webkit browsers
This commit is contained in:
parent
c7c6d95334
commit
aad4711056
@ -14,4 +14,4 @@ fi
|
|||||||
|
|
||||||
wasm-pack build --target web --release
|
wasm-pack build --target web --release
|
||||||
|
|
||||||
gzip -9 -f pkg/lldap_app_bg.wasm
|
gzip -9 -k -f pkg/lldap_app_bg.wasm
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import init, { run_app } from '/pkg/lldap_app.js';
|
import init, { run_app } from '/pkg/lldap_app.js';
|
||||||
async function main() {
|
async function main() {
|
||||||
|
if(navigator.userAgent.indexOf('AppleWebKit') != -1) {
|
||||||
await init('/pkg/lldap_app_bg.wasm');
|
await init('/pkg/lldap_app_bg.wasm');
|
||||||
|
} else {
|
||||||
|
await init('/pkg/lldap_app_bg.wasm.gz');
|
||||||
|
}
|
||||||
run_app();
|
run_app();
|
||||||
}
|
}
|
||||||
main()
|
main()
|
||||||
|
@ -16,7 +16,7 @@ use actix_files::{Files, NamedFile};
|
|||||||
use actix_http::{header, HttpServiceBuilder};
|
use actix_http::{header, HttpServiceBuilder};
|
||||||
use actix_server::ServerBuilder;
|
use actix_server::ServerBuilder;
|
||||||
use actix_service::map_config;
|
use actix_service::map_config;
|
||||||
use actix_web::{dev::AppConfig, guard, middleware, web, App, HttpResponse, Responder};
|
use actix_web::{dev::AppConfig, guard, web, App, HttpResponse, Responder};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use hmac::Hmac;
|
use hmac::Hmac;
|
||||||
use sha2::Sha512;
|
use sha2::Sha512;
|
||||||
@ -68,6 +68,10 @@ pub(crate) fn error_to_http_response(error: TcpError) -> HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn wasm_handler() -> actix_web::Result<impl Responder> {
|
async fn wasm_handler() -> actix_web::Result<impl Responder> {
|
||||||
|
Ok(actix_files::NamedFile::open_async("./app/pkg/lldap_app_bg.wasm").await?)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn wasm_handler_compressed() -> actix_web::Result<impl Responder> {
|
||||||
Ok(
|
Ok(
|
||||||
actix_files::NamedFile::open_async("./app/pkg/lldap_app_bg.wasm.gz")
|
actix_files::NamedFile::open_async("./app/pkg/lldap_app_bg.wasm.gz")
|
||||||
.await?
|
.await?
|
||||||
@ -110,12 +114,9 @@ fn http_config<Backend>(
|
|||||||
.configure(super::graphql::api::configure_endpoint::<Backend>),
|
.configure(super::graphql::api::configure_endpoint::<Backend>),
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/pkg/lldap_app_bg.wasm").route(
|
web::resource("/pkg/lldap_app_bg.wasm.gz").route(web::route().to(wasm_handler_compressed)),
|
||||||
web::route()
|
|
||||||
.wrap(middleware::Compress::default())
|
|
||||||
.to(wasm_handler),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
.service(web::resource("/pkg/lldap_app_bg.wasm").route(web::route().to(wasm_handler)))
|
||||||
// Serve the /pkg path with the compiled WASM app.
|
// Serve the /pkg path with the compiled WASM app.
|
||||||
.service(Files::new("/pkg", "./app/pkg"))
|
.service(Files::new("/pkg", "./app/pkg"))
|
||||||
// Serve static files
|
// Serve static files
|
||||||
|
Loading…
Reference in New Issue
Block a user