refactor(kanban): isolate legacy sync fixture
req: v1_release/002
This commit is contained in:
@@ -375,7 +375,7 @@ struct AppShell {
|
||||
}
|
||||
|
||||
#[derive(Hemplate)]
|
||||
struct SyncShell {
|
||||
struct LegacySyncFixture {
|
||||
runtime_src: &'static str,
|
||||
}
|
||||
|
||||
@@ -504,13 +504,20 @@ async fn main() {
|
||||
.route("/events", get(events))
|
||||
.route("/sync/broadcast", get(sync_broadcast))
|
||||
.route("/sync/ack", get(sync_ack))
|
||||
.route("/sync-demo", get(sync_demo))
|
||||
.route("/sync.js", get(sync_js))
|
||||
.route("/sync/context", get(sync_context))
|
||||
.route("/sync/commands", post(sync_command))
|
||||
.route("/sync/snapshot", get(sync_snapshot))
|
||||
.route(runtime_js_path(), get(runtime))
|
||||
.layer(middleware::from_fn(ordinary_handler_timeout));
|
||||
let ordinary_routes = if std::env::var_os("HEMX_KANBAN_LEGACY_SYNC_FIXTURE").as_deref()
|
||||
== Some(std::ffi::OsStr::new("1"))
|
||||
{
|
||||
ordinary_routes
|
||||
.route("/sync-demo", get(legacy_sync_fixture))
|
||||
.route("/sync.js", get(legacy_sync_fixture_js))
|
||||
} else {
|
||||
ordinary_routes
|
||||
};
|
||||
let app = ordinary_routes
|
||||
.merge(Router::new().route("/sync/acknowledgements", get(sync_acknowledgements)))
|
||||
.with_state(state);
|
||||
@@ -589,9 +596,9 @@ async fn runtime() -> impl IntoResponse {
|
||||
runtime_js()
|
||||
}
|
||||
|
||||
async fn sync_demo() -> impl IntoResponse {
|
||||
async fn legacy_sync_fixture() -> impl IntoResponse {
|
||||
PageResponse::full(
|
||||
ui::page(&SyncShell {
|
||||
ui::page(&LegacySyncFixture {
|
||||
runtime_src: runtime_js_path(),
|
||||
})
|
||||
.into_string(),
|
||||
@@ -600,10 +607,10 @@ async fn sync_demo() -> impl IntoResponse {
|
||||
.fingerprint(ui::BUILD_FINGERPRINT)
|
||||
}
|
||||
|
||||
async fn sync_js() -> impl IntoResponse {
|
||||
async fn legacy_sync_fixture_js() -> impl IntoResponse {
|
||||
(
|
||||
[("content-type", "text/javascript; charset=utf-8")],
|
||||
include_str!("../static/sync.js"),
|
||||
include_str!("../tests/fixtures/legacy-sync.js"),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user