diff --git a/v0.5/Cargo.lock b/v0.5/Cargo.lock index 97431f6df..2ca563273 100644 --- a/v0.5/Cargo.lock +++ b/v0.5/Cargo.lock @@ -238,6 +238,7 @@ version = "0.1.0" dependencies = [ "fastn-continuation", "fastn-section", + "serde", "serde_json", ] diff --git a/v0.5/fastn-router/src/lib.rs b/v0.5/fastn-router/src/lib.rs index 3135d1388..d9c487f67 100644 --- a/v0.5/fastn-router/src/lib.rs +++ b/v0.5/fastn-router/src/lib.rs @@ -21,8 +21,27 @@ pub enum Route { NotFound, // String contains the path, the data may contain more than that was passed to route, e.g., it // can extract some extra path-specific data from FASTN.ftd file - Document(String, serde_json::Value), - Wasm(String, serde_json::Value), + Document(Document), + Wasm(String), Redirect(String), Static(String), } + +pub struct Document { + // this is private yet + #[expect(unused)] + pub(crate) path: String, + #[expect(unused)] + pub(crate) partial: serde_json::Value, + #[expect(unused)] + pub(crate) keys: Vec, +} + +#[derive(Debug)] +pub enum RouterError {} + +impl Document { + pub fn with_data(self, _data: &[u8]) -> Result<(String, serde_json::Value), RouterError> { + todo!() + } +} diff --git a/v0.5/fastn-router/src/route.rs b/v0.5/fastn-router/src/route.rs index c8171edab..8ae8a5c2f 100644 --- a/v0.5/fastn-router/src/route.rs +++ b/v0.5/fastn-router/src/route.rs @@ -1,10 +1,9 @@ impl fastn_router::Router { - pub fn route( - &self, - _path: &str, - _method: fastn_router::Method, - _data: &[u8], - ) -> fastn_router::Route { - fastn_router::Route::Document("index.ftd".to_string(), serde_json::Value::Null) + pub fn route(&self, _path: &str, _method: fastn_router::Method) -> fastn_router::Route { + fastn_router::Route::Document(fastn_router::Document { + path: "index.ftd".to_string(), + keys: vec![], + partial: serde_json::Value::Null, + }) } } diff --git a/v0.5/fastn-unresolved/src/lib.rs b/v0.5/fastn-unresolved/src/lib.rs index 9d53094f9..297e989e4 100644 --- a/v0.5/fastn-unresolved/src/lib.rs +++ b/v0.5/fastn-unresolved/src/lib.rs @@ -63,7 +63,7 @@ pub enum SoMBase { pub struct Document { pub aliases: Option, pub module: fastn_unresolved::Module, - pub package: fastn_unresolved::Package, // auto import, dependencies + // pub package: fastn_unresolved::Package, // auto import, dependencies pub module_doc: Option, pub definitions: Vec, pub content: Vec, diff --git a/v0.5/fastn/src/commands/render.rs b/v0.5/fastn/src/commands/render.rs index 0861f9671..2ce3a8a40 100644 --- a/v0.5/fastn/src/commands/render.rs +++ b/v0.5/fastn/src/commands/render.rs @@ -1,8 +1,9 @@ impl fastn::commands::Render { pub async fn run(self, _package: &mut fastn_package::Package, router: fastn_router::Router) { - let route = router.route("/", fastn_router::Method::Get, &[]); + let route = router.route("/", fastn_router::Method::Get); match route { - fastn_router::Route::Document(path, data) => { + fastn_router::Route::Document(doc) => { + let (path, data) = doc.with_data(&[]).unwrap(); let html = fastn::commands::render::render_document(path.as_str(), data, self.strict) .await;