Revert "improved documentation and refactored naming to be more self-explanatory"

This reverts commit adfbb6c380.
This commit is contained in:
Pascal committed 2023-12-07 17:11:56 +01:00
1 parent adfbb6c380
commit 906c466e78
91 files changed
+1553 -1663

No files matched your search

@@ -37,13 +37,12 @@ fn main() {
//To enable Private cookies for integrity, and authenticity please check the next Example.
let session_config = SessionConfig::default().with_table_name("test_table");
let auth_config = AuthConfig::<i64>::default().with_anonymous_user_id(Some(1));
let session_store =
SessionStore::<SessionSqlitePool>::new(
Some(pool.clone().into()),
session_config,
)
.await
.unwrap();
let session_store = SessionStore::<SessionSqlitePool>::new(
Some(pool.clone().into()),
session_config,
)
.await
.unwrap();
//Create the Database table for storing our Session Data.
session_store.initiate().await.unwrap();
@@ -16,9 +16,9 @@ use serde::{Deserialize, Serialize};
#[tokio::main]
async fn main() {
pre_cache_static_routes_with_props(
&ServeConfigBuilder::new_with_router(
dioxus_fullstack::router::FullstackRouterConfig::<Route>::default()
)
&ServeConfigBuilder::new_with_router(dioxus_fullstack::router::FullstackRouterConfig::<
Route,
>::default())
.assets_path("docs")
.incremental(IncrementalRendererConfig::default().static_dir("docs"))
.build(),
@@ -280,13 +280,12 @@ where
let assets_path = assets_path.into();
// Serve all files in dist folder except index.html
let dir =
std::fs::read_dir(&assets_path).unwrap_or_else(|e| {
panic!(
"Couldn't read assets directory at {:?}: {}",
&assets_path, e
)
});
let dir = std::fs::read_dir(&assets_path).unwrap_or_else(|e| {
panic!(
"Couldn't read assets directory at {:?}: {}",
&assets_path, e
)
});
for entry in dir.flatten() {
let path = entry.path();
@@ -298,9 +297,9 @@ where
.unwrap()
.iter()
.map(|segment| {
segment.to_str().unwrap_or_else(
|| panic!("Failed to convert path segment {:?} to string", segment)
)
segment.to_str().unwrap_or_else(|| {
panic!("Failed to convert path segment {:?} to string", segment)
})
})
.collect::<Vec<_>>()
.join("/");
@@ -244,13 +244,12 @@ impl DioxusRouterExt for Router {
let assets_path = assets_path.into();
// Serve all files in dist folder except index.html
let dir =
std::fs::read_dir(&assets_path).unwrap_or_else(|e| {
panic!(
"Couldn't read assets directory at {:?}: {}",
&assets_path, e
)
});
let dir = std::fs::read_dir(&assets_path).unwrap_or_else(|e| {
panic!(
"Couldn't read assets directory at {:?}: {}",
&assets_path, e
)
});
for entry in dir.flatten() {
let path = entry.path();
@@ -262,9 +261,9 @@ impl DioxusRouterExt for Router {
.unwrap()
.iter()
.map(|segment| {
segment.to_str().unwrap_or_else(
|| panic!("Failed to convert path segment {:?} to string", segment)
)
segment.to_str().unwrap_or_else(|| {
panic!("Failed to convert path segment {:?} to string", segment)
})
})
.collect::<Vec<_>>()
.join("/");
@@ -7,14 +7,13 @@ use super::HTMLDataCursor;
#[allow(unused)]
pub(crate) fn serde_from_bytes<T: DeserializeOwned>(string: &[u8]) -> Option<T> {
let decompressed =
match STANDARD.decode(string) {
Ok(bytes) => bytes,
Err(err) => {
tracing::error!("Failed to decode base64: {}", err);
return None;
}
};
let decompressed = match STANDARD.decode(string) {
Ok(bytes) => bytes,
Err(err) => {
tracing::error!("Failed to decode base64: {}", err);
return None;
}
};
match postcard::from_bytes(&decompressed) {
Ok(data) => Some(data),
+5 -3
View File
@@ -46,9 +46,11 @@ where
> + Send,
>,
> {
let fut = self.call(req).instrument(
tracing::trace_span!("service", "{}", std::any::type_name::<S>())
);
let fut = self.call(req).instrument(tracing::trace_span!(
"service",
"{}",
std::any::type_name::<S>()
));
Box::pin(async move { fut.await.map_err(|err| err.into()) })
}
}
+4 -5
View File
@@ -91,11 +91,10 @@ impl SsrRendererPool {
Ok((freshness, html))
}
Self::Incremental(pool) => {
let mut renderer = pool
.write()
.unwrap()
.pop()
.unwrap_or_else(|| incremental_pre_renderer(cfg.incremental.as_ref().unwrap()));
let mut renderer =
pool.write().unwrap().pop().unwrap_or_else(|| {
incremental_pre_renderer(cfg.incremental.as_ref().unwrap())
});
let (tx, rx) = tokio::sync::oneshot::channel();
+7 -9
View File
@@ -122,16 +122,14 @@ fn load_index_html(path: PathBuf, root_id: &'static str) -> IndexHtml {
let (pre_main, post_main) = contents.split_once(&format!("id=\"{root_id}\"")).unwrap_or_else(|| panic!("Failed to find id=\"{root_id}\" in index.html. The id is used to inject the application into the page."));
let post_main =
post_main.split_once('>').unwrap_or_else(
|| panic!("Failed to find closing > after id=\"{root_id}\" in index.html.")
);
let post_main = post_main.split_once('>').unwrap_or_else(|| {
panic!("Failed to find closing > after id=\"{root_id}\" in index.html.")
});
let (pre_main, post_main) =
(
pre_main.to_string() + &format!("id=\"{root_id}\"") + post_main.0 + ">",
post_main.1.to_string(),
);
let (pre_main, post_main) = (
pre_main.to_string() + &format!("id=\"{root_id}\"") + post_main.0 + ">",
post_main.1.to_string(),
);
IndexHtml {
pre_main,
+9 -9
View File
@@ -22,9 +22,9 @@ impl Default for DioxusServerContext {
fn default() -> Self {
Self {
shared_context: std::sync::Arc::new(std::sync::RwLock::new(anymap::Map::new())),
response_parts: std::sync::Arc::new(
RwLock::new(http::response::Response::new(()).into_parts().0)
),
response_parts: std::sync::Arc::new(RwLock::new(
http::response::Response::new(()).into_parts().0,
)),
parts: std::sync::Arc::new(RwLock::new(http::request::Request::new(()).into_parts().0)),
html_data: Arc::new(RwLock::new(HTMLData::default())),
}
@@ -45,9 +45,9 @@ mod server_fn_impl {
Self {
parts: parts.into(),
shared_context: Arc::new(RwLock::new(SendSyncAnyMap::new())),
response_parts: std::sync::Arc::new(
RwLock::new(http::response::Response::new(()).into_parts().0)
),
response_parts: std::sync::Arc::new(RwLock::new(
http::response::Response::new(()).into_parts().0,
)),
html_data: Arc::new(RwLock::new(HTMLData::default())),
}
}
@@ -221,9 +221,9 @@ impl<T: Send + Sync + Clone + 'static> FromServerContext for FromContext<T> {
type Rejection = NotFoundInServerContext<T>;
async fn from_request(req: &DioxusServerContext) -> Result<Self, Self::Rejection> {
Ok(Self(req.clone().get::<T>().ok_or_else(
|| NotFoundInServerContext::<T>(std::marker::PhantomData::<T>)
)?))
Ok(Self(req.clone().get::<T>().ok_or_else(|| {
NotFoundInServerContext::<T>(std::marker::PhantomData::<T>)
})?))
}
}