Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Jan 17, 2024
1 parent 22e6a13 commit 8b5dd99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion server_fn/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use thiserror::Error;
use url::Url;

/// A custom header that can be used to indicate a server function returned an error.
pub const SERVER_FN_ERROR_HEADER: &'static str = "serverfnerror";
pub const SERVER_FN_ERROR_HEADER: &str = "serverfnerror";

/// This is a result type into which any error can be converted,
/// and which can be used directly in your `view`.
Expand Down
19 changes: 11 additions & 8 deletions server_fn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ use codec::{Encoding, FromReq, FromRes, IntoReq, IntoRes};
pub use const_format;
use dashmap::DashMap;
pub use error::ServerFnError;
use error::{ServerFnErrorSerde, ServerFnUrlError};
use error::ServerFnErrorSerde;
#[cfg(feature = "form-redirects")]
use error::ServerFnUrlError;
use http::Method;
use middleware::{Layer, Service};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -240,16 +242,17 @@ where
// Server functions can either be called by a real Client,
// or directly by an HTML <form>. If they're accessed by a <form>, default to
// redirecting back to the Referer.
let accepts_html = if cfg!(feature = "form-redirects") {
req.accepts()
.map(|n| n.contains("text/html"))
.unwrap_or(false)
} else {
false
};
#[cfg(feature = "form-redirects")]
let accepts_html = req
.accepts()
.map(|n| n.contains("text/html"))
.unwrap_or(false);
#[cfg(feature = "form-redirects")]
let mut referer = req.referer().as_deref().map(ToOwned::to_owned);

async move {
#[allow(unused_variables, unused_mut)]
// used in form redirects feature
let (mut res, err) = Self::execute_on_server(req)
.await
.map(|res| (res, None))
Expand Down

0 comments on commit 8b5dd99

Please sign in to comment.