fix response spelling

This commit is contained in:
Evan Almloff committed 2023-05-11 18:40:02 -05:00
1 parent 40d30bb434
commit 4a8542c28e
10 files changed
+19 -19

No files matched your search

+1 -1
View File
@@ -103,7 +103,7 @@ async fn double_server(cx: DioxusServerContext, number: usize) -> Result<usize,
); );
// Set the cache control header to 1 hour on the post request // Set the cache control header to 1 hour on the post request
cx.responce_headers_mut() cx.response_headers_mut()
.insert("Cache-Control", "max-age=3600".parse().unwrap()); .insert("Cache-Control", "max-age=3600".parse().unwrap());
println!("server calculated {result}"); println!("server calculated {result}");
+1 -1
View File
@@ -121,7 +121,7 @@ async fn double_server(cx: DioxusServerContext, number: usize) -> Result<usize,
); );
// Set the cache control header to 1 hour on the post request // Set the cache control header to 1 hour on the post request
cx.responce_headers_mut() cx.response_headers_mut()
.insert("Cache-Control", "max-age=3600".parse().unwrap()); .insert("Cache-Control", "max-age=3600".parse().unwrap());
// Get the server function state // Get the server function state
@@ -87,7 +87,7 @@ fn app(cx: Scope<AppProps>) -> Element {
#[server(PostServerData)] #[server(PostServerData)]
async fn post_server_data(cx: DioxusServerContext, data: String) -> Result<(), ServerFnError> { async fn post_server_data(cx: DioxusServerContext, data: String) -> Result<(), ServerFnError> {
// The server context contains information about the current request and allows you to modify the response. // The server context contains information about the current request and allows you to modify the response.
cx.responce_headers_mut() cx.response_headers_mut()
.insert("Set-Cookie", "foo=bar".parse().unwrap()); .insert("Set-Cookie", "foo=bar".parse().unwrap());
println!("Server received: {}", data); println!("Server received: {}", data);
println!("Request parts are {:?}", cx.request_parts()); println!("Request parts are {:?}", cx.request_parts());
@@ -83,7 +83,7 @@ fn app(cx: Scope<AppProps>) -> Element {
#[server(PostServerData)] #[server(PostServerData)]
async fn post_server_data(cx: DioxusServerContext, data: String) -> Result<(), ServerFnError> { async fn post_server_data(cx: DioxusServerContext, data: String) -> Result<(), ServerFnError> {
// The server context contains information about the current request and allows you to modify the response. // The server context contains information about the current request and allows you to modify the response.
cx.responce_headers_mut() cx.response_headers_mut()
.insert("Set-Cookie", "foo=bar".parse().unwrap()); .insert("Set-Cookie", "foo=bar".parse().unwrap());
println!("Server received: {}", data); println!("Server received: {}", data);
println!("Request parts are {:?}", cx.request_parts()); println!("Request parts are {:?}", cx.request_parts());
@@ -80,7 +80,7 @@ fn app(cx: Scope<AppProps>) -> Element {
#[server(PostServerData)] #[server(PostServerData)]
async fn post_server_data(cx: DioxusServerContext, data: String) -> Result<(), ServerFnError> { async fn post_server_data(cx: DioxusServerContext, data: String) -> Result<(), ServerFnError> {
// The server context contains information about the current request and allows you to modify the response. // The server context contains information about the current request and allows you to modify the response.
cx.responce_headers_mut() cx.response_headers_mut()
.insert("Set-Cookie", "foo=bar".parse().unwrap()); .insert("Set-Cookie", "foo=bar".parse().unwrap());
println!("Server received: {}", data); println!("Server received: {}", data);
println!("Request parts are {:?}", cx.request_parts()); println!("Request parts are {:?}", cx.request_parts());
@@ -401,8 +401,8 @@ pub async fn server_fn_handler(
.get("Accept") .get("Accept")
.and_then(|value| value.to_str().ok()); .and_then(|value| value.to_str().ok());
let mut res = Response::builder(); let mut res = Response::builder();
*res.headers_mut().expect("empty responce should be valid") = *res.headers_mut().expect("empty response should be valid") =
server_context.take_responce_headers(); server_context.take_response_headers();
if accept_header == Some("application/json") if accept_header == Some("application/json")
|| accept_header || accept_header
== Some( == Some(
@@ -339,7 +339,7 @@ impl<P: Clone + serde::Serialize + Send + Sync + 'static> Handler for SSRHandler
res.write_body(renderer_pool.render_vdom(&vdom, &self.cfg)) res.write_body(renderer_pool.render_vdom(&vdom, &self.cfg))
.unwrap(); .unwrap();
*res.headers_mut() = server_context.take_responce_headers(); *res.headers_mut() = server_context.take_response_headers();
} }
} }
@@ -408,7 +408,7 @@ impl ServerFnHandler {
let result = resp_rx.await.unwrap(); let result = resp_rx.await.unwrap();
// Set the headers from the server context // Set the headers from the server context
*res.headers_mut() = server_context.take_responce_headers(); *res.headers_mut() = server_context.take_response_headers();
match result { match result {
Ok(serialized) => { Ok(serialized) => {
@@ -196,7 +196,7 @@ pub fn render_ssr<P: Clone + serde::Serialize + Send + Sync + 'static>(
let mut res = Response::builder(); let mut res = Response::builder();
*res.headers_mut().expect("empty request should be valid") = *res.headers_mut().expect("empty request should be valid") =
server_context.take_responce_headers(); server_context.take_response_headers();
res.header("Content-Type", "text/html") res.header("Content-Type", "text/html")
.body(Bytes::from(html)) .body(Bytes::from(html))
@@ -289,7 +289,7 @@ pub async fn server_fn_handler(
let mut res = Response::builder(); let mut res = Response::builder();
*res.headers_mut().expect("empty request should be valid") = *res.headers_mut().expect("empty request should be valid") =
server_context.take_responce_headers(); server_context.take_response_headers();
if accept_header == Some("application/json") if accept_header == Some("application/json")
|| accept_header || accept_header
+7 -7
View File
@@ -93,32 +93,32 @@ mod server_fn_impl {
} }
/// Get the headers from the server context /// Get the headers from the server context
pub fn responce_headers(&self) -> RwLockReadGuard<'_, hyper::header::HeaderMap> { pub fn response_headers(&self) -> RwLockReadGuard<'_, hyper::header::HeaderMap> {
self.try_responce_headers() self.try_response_headers()
.expect("Failed to get headers from server context") .expect("Failed to get headers from server context")
} }
/// Try to get the headers from the server context /// Try to get the headers from the server context
pub fn try_responce_headers( pub fn try_response_headers(
&self, &self,
) -> LockResult<RwLockReadGuard<'_, hyper::header::HeaderMap>> { ) -> LockResult<RwLockReadGuard<'_, hyper::header::HeaderMap>> {
self.headers.read() self.headers.read()
} }
/// Get the headers mutably from the server context /// Get the headers mutably from the server context
pub fn responce_headers_mut(&self) -> RwLockWriteGuard<'_, hyper::header::HeaderMap> { pub fn response_headers_mut(&self) -> RwLockWriteGuard<'_, hyper::header::HeaderMap> {
self.try_responce_headers_mut() self.try_response_headers_mut()
.expect("Failed to get headers mutably from server context") .expect("Failed to get headers mutably from server context")
} }
/// Try to get the headers mut from the server context /// Try to get the headers mut from the server context
pub fn try_responce_headers_mut( pub fn try_response_headers_mut(
&self, &self,
) -> LockResult<RwLockWriteGuard<'_, hyper::header::HeaderMap>> { ) -> LockResult<RwLockWriteGuard<'_, hyper::header::HeaderMap>> {
self.headers.write() self.headers.write()
} }
pub(crate) fn take_responce_headers(&self) -> hyper::header::HeaderMap { pub(crate) fn take_response_headers(&self) -> hyper::header::HeaderMap {
let mut headers = self.headers.write().unwrap(); let mut headers = self.headers.write().unwrap();
std::mem::take(&mut *headers) std::mem::take(&mut *headers)
} }
+1 -1
View File
@@ -254,7 +254,7 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
res = rx.try_next().transpose().unwrap().ok(); res = rx.try_next().transpose().unwrap().ok();
} }
// Todo: This is currently disabled because it has a negative impact on responce times for events but it could be re-enabled for tasks // Todo: This is currently disabled because it has a negative impact on response times for events but it could be re-enabled for tasks
// Jank free rendering // Jank free rendering
// //
// 1. wait for the browser to give us "idle" time // 1. wait for the browser to give us "idle" time