mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
fix response spelling
This commit is contained in:
parent
40d30bb434
commit
4a8542c28e
10 changed files with 19 additions and 19 deletions
|
@ -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
|
||||
cx.responce_headers_mut()
|
||||
cx.response_headers_mut()
|
||||
.insert("Cache-Control", "max-age=3600".parse().unwrap());
|
||||
|
||||
println!("server calculated {result}");
|
||||
|
|
|
@ -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
|
||||
cx.responce_headers_mut()
|
||||
cx.response_headers_mut()
|
||||
.insert("Cache-Control", "max-age=3600".parse().unwrap());
|
||||
|
||||
// Get the server function state
|
||||
|
|
|
@ -87,7 +87,7 @@ fn app(cx: Scope<AppProps>) -> Element {
|
|||
#[server(PostServerData)]
|
||||
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.
|
||||
cx.responce_headers_mut()
|
||||
cx.response_headers_mut()
|
||||
.insert("Set-Cookie", "foo=bar".parse().unwrap());
|
||||
println!("Server received: {}", data);
|
||||
println!("Request parts are {:?}", cx.request_parts());
|
||||
|
|
|
@ -83,7 +83,7 @@ fn app(cx: Scope<AppProps>) -> Element {
|
|||
#[server(PostServerData)]
|
||||
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.
|
||||
cx.responce_headers_mut()
|
||||
cx.response_headers_mut()
|
||||
.insert("Set-Cookie", "foo=bar".parse().unwrap());
|
||||
println!("Server received: {}", data);
|
||||
println!("Request parts are {:?}", cx.request_parts());
|
||||
|
|
|
@ -80,7 +80,7 @@ fn app(cx: Scope<AppProps>) -> Element {
|
|||
#[server(PostServerData)]
|
||||
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.
|
||||
cx.responce_headers_mut()
|
||||
cx.response_headers_mut()
|
||||
.insert("Set-Cookie", "foo=bar".parse().unwrap());
|
||||
println!("Server received: {}", data);
|
||||
println!("Request parts are {:?}", cx.request_parts());
|
||||
|
|
|
@ -401,8 +401,8 @@ pub async fn server_fn_handler(
|
|||
.get("Accept")
|
||||
.and_then(|value| value.to_str().ok());
|
||||
let mut res = Response::builder();
|
||||
*res.headers_mut().expect("empty responce should be valid") =
|
||||
server_context.take_responce_headers();
|
||||
*res.headers_mut().expect("empty response should be valid") =
|
||||
server_context.take_response_headers();
|
||||
if accept_header == Some("application/json")
|
||||
|| accept_header
|
||||
== 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))
|
||||
.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();
|
||||
|
||||
// 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 {
|
||||
Ok(serialized) => {
|
||||
|
|
|
@ -196,7 +196,7 @@ pub fn render_ssr<P: Clone + serde::Serialize + Send + Sync + 'static>(
|
|||
let mut res = Response::builder();
|
||||
|
||||
*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")
|
||||
.body(Bytes::from(html))
|
||||
|
@ -289,7 +289,7 @@ pub async fn server_fn_handler(
|
|||
let mut res = Response::builder();
|
||||
|
||||
*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")
|
||||
|| accept_header
|
||||
|
|
|
@ -93,32 +93,32 @@ mod server_fn_impl {
|
|||
}
|
||||
|
||||
/// Get the headers from the server context
|
||||
pub fn responce_headers(&self) -> RwLockReadGuard<'_, hyper::header::HeaderMap> {
|
||||
self.try_responce_headers()
|
||||
pub fn response_headers(&self) -> RwLockReadGuard<'_, hyper::header::HeaderMap> {
|
||||
self.try_response_headers()
|
||||
.expect("Failed to get headers from server context")
|
||||
}
|
||||
|
||||
/// Try to get the headers from the server context
|
||||
pub fn try_responce_headers(
|
||||
pub fn try_response_headers(
|
||||
&self,
|
||||
) -> LockResult<RwLockReadGuard<'_, hyper::header::HeaderMap>> {
|
||||
self.headers.read()
|
||||
}
|
||||
|
||||
/// Get the headers mutably from the server context
|
||||
pub fn responce_headers_mut(&self) -> RwLockWriteGuard<'_, hyper::header::HeaderMap> {
|
||||
self.try_responce_headers_mut()
|
||||
pub fn response_headers_mut(&self) -> RwLockWriteGuard<'_, hyper::header::HeaderMap> {
|
||||
self.try_response_headers_mut()
|
||||
.expect("Failed to get headers mutably from 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,
|
||||
) -> LockResult<RwLockWriteGuard<'_, hyper::header::HeaderMap>> {
|
||||
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();
|
||||
std::mem::take(&mut *headers)
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
// 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
|
||||
//
|
||||
// 1. wait for the browser to give us "idle" time
|
||||
|
|
Loading…
Reference in a new issue