diff --git a/cot-core/src/error/error_impl.rs b/cot-core/src/error/error_impl.rs index c38bf28e..db594083 100644 --- a/cot-core/src/error/error_impl.rs +++ b/cot-core/src/error/error_impl.rs @@ -38,31 +38,6 @@ impl Error { } } - /// Create a new error with a custom error message or error type. - /// - /// # Examples - /// - /// ``` - /// use cot::Error; - /// - /// let error = Error::custom("An error occurred"); - /// let error = Error::custom(std::io::Error::new( - /// std::io::ErrorKind::Other, - /// "An error occurred", - /// )); - /// ``` - #[deprecated( - note = "Use `cot::Error::internal` or `cot::Error::with_status` instead", - since = "0.4.0" - )] - #[must_use] - pub fn custom(error: E) -> Self - where - E: Into>, - { - Self::internal(error) - } - /// Create a new error with a custom error message or error type. /// /// The error will be associated with a 500 Internal Server Error @@ -124,32 +99,6 @@ impl Error { Self::wrap(WithStatusCode(error)) } - /// Create a new admin panel error with a custom error message or error - /// type. - /// - /// # Examples - /// - /// ``` - /// use cot::Error; - /// - /// let error = Error::admin("An error occurred"); - /// let error = Error::admin(std::io::Error::new( - /// std::io::ErrorKind::Other, - /// "An error occurred", - /// )); - /// ``` - #[deprecated( - note = "Use `cot::Error::wrap`, `cot::Error::internal`, or \ - `cot::Error::with_status` directly instead", - since = "0.4.0" - )] - pub fn admin(error: E) -> Self - where - E: Into>, - { - Self::internal(error) - } - /// Returns the HTTP status code associated with this error. /// /// This method returns the appropriate HTTP status code that should be diff --git a/cot-core/src/response.rs b/cot-core/src/response.rs index f9643578..01f60442 100644 --- a/cot-core/src/response.rs +++ b/cot-core/src/response.rs @@ -1,4 +1,4 @@ -use crate::{Body, StatusCode}; +use crate::Body; mod into_response; /// Derive macro for the [`IntoResponse`] trait. @@ -90,30 +90,6 @@ pub trait ResponseExt: Sized + private::Sealed { /// ``` #[must_use] fn builder() -> http::response::Builder; - - /// Create a new redirect response. - /// - /// This creates a new [`Response`] object with a status code of - /// [`StatusCode::SEE_OTHER`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/303) - /// and a `Location` header set to the provided location. - /// - /// # Examples - /// - /// ``` - /// use cot::StatusCode; - /// use cot::response::{Response, ResponseExt}; - /// - /// let response = Response::new_redirect("http://example.com"); - /// ``` - /// - /// # See also - /// - /// * [`cot::reverse_redirect!`](../../cot/macro.reverse_redirect!.html) – a - /// more ergonomic way to create redirects to internal views (available in - /// the `cot` crate) - #[must_use] - #[deprecated(since = "0.5.0", note = "Use Redirect::new() instead")] - fn new_redirect>(location: T) -> Self; } impl private::Sealed for Response {} @@ -122,14 +98,6 @@ impl ResponseExt for Response { fn builder() -> http::response::Builder { http::Response::builder() } - - fn new_redirect>(location: T) -> Self { - http::Response::builder() - .status(StatusCode::SEE_OTHER) - .header(http::header::LOCATION, location.into()) - .body(Body::empty()) - .expect(RESPONSE_BUILD_FAILURE) - } } /// A redirect response. @@ -182,9 +150,9 @@ impl Redirect { #[cfg(test)] mod tests { use super::*; + use crate::StatusCode; use crate::body::BodyInner; use crate::headers::JSON_CONTENT_TYPE; - use crate::response::{Response, ResponseExt}; #[test] #[cfg(feature = "json")] @@ -213,18 +181,6 @@ mod tests { } } - #[test] - #[expect(deprecated)] - fn response_new_redirect() { - let location = "http://example.com"; - let response = Response::new_redirect(location); - assert_eq!(response.status(), StatusCode::SEE_OTHER); - assert_eq!( - response.headers().get(http::header::LOCATION).unwrap(), - location - ); - } - #[test] fn response_new_redirect_struct() { let location = "http://example.com"; diff --git a/cot/src/request.rs b/cot/src/request.rs index 42e7ca4a..f4dbb38b 100644 --- a/cot/src/request.rs +++ b/cot/src/request.rs @@ -185,28 +185,6 @@ pub trait RequestExt: private::Sealed { #[must_use] fn path_params_mut(&mut self) -> &mut PathParams; - /// Get the database. - /// - /// # Examples - /// - /// ``` - /// use cot::request::{Request, RequestExt}; - /// use cot::response::Response; - /// - /// async fn my_handler(mut request: Request) -> cot::Result { - /// let db = request.db(); - /// // ... do something with the database - /// # unimplemented!() - /// } - /// ``` - #[cfg(feature = "db")] - #[must_use] - #[deprecated( - since = "0.5.0", - note = "use request extractors (`FromRequestHead`) instead" - )] - fn db(&self) -> &crate::db::Database; - /// Get the content type of the request. /// /// # Examples @@ -315,11 +293,6 @@ impl RequestExt for Request { self.extensions_mut().get_or_insert_default::() } - #[cfg(feature = "db")] - fn db(&self) -> &crate::db::Database { - self.context().database() - } - fn content_type(&self) -> Option<&http::HeaderValue> { self.headers().get(http::header::CONTENT_TYPE) } @@ -375,11 +348,6 @@ impl RequestExt for RequestHead { self.extensions.get_or_insert_default::() } - #[cfg(feature = "db")] - fn db(&self) -> &crate::db::Database { - self.context().database() - } - fn content_type(&self) -> Option<&http::HeaderValue> { self.headers.get(http::header::CONTENT_TYPE) }