Skip to content

Commit f813f7c

Browse files
committed
final review changes
1 parent cb940a3 commit f813f7c

27 files changed

Lines changed: 93 additions & 125 deletions

cot-core/src/request.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
//! HTTP request type and helper methods.
2-
//!
3-
//! Cot uses the [`Request`](http::Request) type from the [`http`] crate
4-
//! to represent incoming HTTP requests. However, it also provides a
5-
//! [`RequestExt`](../../cot/request/trait.RequestExt.html) trait that contain
6-
//! various helper methods for working with HTTP requests. These methods are
7-
//! used to access the application context, project configuration, path
8-
//! parameters, and more. You probably want to have a `use` statement for
9-
//! [`RequestExt`](../../cot/request/trait.RequestExt.html) in your code most of
10-
//! the time to be able to use these functions:
11-
//!
12-
//! ```
13-
//! use cot::request::RequestExt;
14-
//! ```
15-
161
use indexmap::IndexMap;
172

183
use crate::Body;

cot-core/src/request/extractors.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ use crate::json::Json;
5757
use crate::request::{InvalidContentType, PathParams, Request, RequestHead};
5858
use crate::{Body, Method};
5959

60-
/// Trait for extractors that consume the request body.
61-
///
62-
/// Extractors implementing this trait are used in route handlers that consume
63-
/// the request body and therefore can only be used once per request.
64-
///
65-
/// See [`crate::request::extractors`] documentation for more information about
66-
/// extractors.
6760
pub trait FromRequest: Sized {
6861
/// Extracts data from the request.
6962
///
@@ -83,14 +76,6 @@ impl FromRequest for Request {
8376
}
8477
}
8578

86-
/// Trait for extractors that don't consume the request body.
87-
///
88-
/// Extractors implementing this trait are used in route handlers that don't
89-
/// consume the request and therefore can be used multiple times per request.
90-
///
91-
/// If you need to consume the body of the request, use [`FromRequest`] instead.
92-
///
93-
/// See [`crate::request::extractors`] documentation for more information about
9479
/// extractors.
9580
pub trait FromRequestHead: Sized {
9681
/// Extracts data from the request head.
@@ -105,7 +90,7 @@ pub trait FromRequestHead: Sized {
10590
/// An extractor that extracts data from the URL params.
10691
///
10792
/// The extractor is generic over a type that implements
108-
/// `serde::de::DeserializeOwned`.
93+
/// [`DeserializeOwned`].
10994
///
11095
/// # Examples
11196
///
@@ -160,7 +145,7 @@ impl<D: DeserializeOwned> FromRequestHead for Path<D> {
160145
/// An extractor that extracts data from the URL query parameters.
161146
///
162147
/// The extractor is generic over a type that implements
163-
/// `serde::de::DeserializeOwned`.
148+
/// [`DeserializeOwned`].
164149
///
165150
/// # Example
166151
///
@@ -223,7 +208,7 @@ struct QueryParametersParseError(serde_path_to_error::Error<serde::de::value::Er
223208
impl_into_cot_error!(QueryParametersParseError, BAD_REQUEST);
224209

225210
/// Extractor that gets the request body as JSON and deserializes it into a type
226-
/// `T` implementing `serde::de::DeserializeOwned`.
211+
/// `T` implementing [`DeserializeOwned`].
227212
///
228213
/// The content type of the request must be `application/json`.
229214
///

cot-core/src/response.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
//! HTTP response type and helper methods.
2-
//!
3-
//! Cot uses the [`Response`](http::Response) type from the [`http`] crate
4-
//! to represent outgoing HTTP responses. However, it also provides a
5-
//! [`ResponseExt`] trait that contain various helper methods for working with
6-
//! HTTP responses. These methods are used to create new responses with HTML
7-
//! content types, redirects, and more. You probably want to have a `use`
8-
//! statement for [`ResponseExt`] in your code most of the time to be able to
9-
//! use these functions:
10-
//!
11-
//! ```
12-
//! use cot::response::ResponseExt;
13-
//! ```
14-
151
use crate::{Body, StatusCode};
162

173
mod into_response;

cot/src/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
1616
/// backwards compatible shim for form Password type.
1717
use async_trait::async_trait;
1818
use chrono::{DateTime, FixedOffset};
19+
use cot_core::error::impl_into_cot_error;
1920
use derive_more::with_trait::Debug;
2021
#[cfg(test)]
2122
use mockall::automock;
@@ -27,7 +28,6 @@ use thiserror::Error;
2728
use crate::config::SecretKey;
2829
#[cfg(feature = "db")]
2930
use crate::db::{ColumnType, DatabaseField, DbValue, FromDbValue, SqlxValueRef, ToDbValue};
30-
use crate::error::impl_into_cot_error;
3131
use crate::request::{Request, RequestExt};
3232
use crate::session::Session;
3333

cot/src/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ use std::future::Future;
116116
use std::sync::Arc;
117117

118118
use cot::config::CacheStoreTypeConfig;
119+
use cot_core::error::impl_into_cot_error;
119120
use derive_more::with_trait::Debug;
120121
use serde::Serialize;
121122
use serde::de::DeserializeOwned;
@@ -126,7 +127,6 @@ use crate::cache::store::memory::Memory;
126127
use crate::cache::store::redis::Redis;
127128
use crate::cache::store::{BoxCacheStore, CacheStore};
128129
use crate::config::{CacheConfig, Timeout};
129-
use crate::error::impl_into_cot_error;
130130

131131
/// An error that can occur when interacting with the cache.
132132
#[derive(Debug, Error)]

cot/src/cache/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ pub mod redis;
1212
use std::fmt::Debug;
1313
use std::pin::Pin;
1414

15+
use cot_core::error::impl_into_cot_error;
1516
use serde_json::Value;
1617
use thiserror::Error;
1718

1819
use crate::config::Timeout;
19-
use crate::error::impl_into_cot_error;
2020

2121
const CACHE_STORE_ERROR_PREFIX: &str = "cache store error:";
2222

cot/src/cache/store/redis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
//! # }
1919
use cot::cache::store::CacheStoreResult;
2020
use cot::config::Timeout;
21+
use cot_core::error::impl_into_cot_error;
2122
use deadpool_redis::{Config, Connection, Pool, Runtime};
2223
use redis::{AsyncCommands, SetExpiry, SetOptions};
2324
use serde_json::Value;
2425
use thiserror::Error;
2526

2627
use crate::cache::store::{CacheStore, CacheStoreError};
2728
use crate::config::CacheUrl;
28-
use crate::error::impl_into_cot_error;
2929

3030
const ERROR_PREFIX: &str = "redis cache store error:";
3131

cot/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::path::PathBuf;
1919
use std::time::Duration;
2020

2121
use chrono::{DateTime, FixedOffset, Utc};
22+
use cot_core::error::impl_into_cot_error;
2223
use derive_builder::Builder;
2324
use derive_more::with_trait::{Debug, From};
2425
use serde::{Deserialize, Serialize};
@@ -27,7 +28,6 @@ use thiserror::Error;
2728

2829
#[cfg(feature = "email")]
2930
use crate::email::transport::smtp::Mechanism;
30-
use crate::error::impl_into_cot_error;
3131
use crate::utils::chrono::DateTimeWithOffsetAdapter;
3232

3333
/// The configuration for a project.

cot/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::str::FromStr;
2121
use std::sync::Arc;
2222

2323
use async_trait::async_trait;
24+
use cot_core::error::impl_into_cot_error;
2425
pub use cot_macros::{model, query};
2526
use derive_more::{Debug, Deref, Display};
2627
#[cfg(test)]
@@ -42,7 +43,6 @@ use crate::db::impl_postgres::{DatabasePostgres, PostgresRow, PostgresValueRef};
4243
#[cfg(feature = "sqlite")]
4344
use crate::db::impl_sqlite::{DatabaseSqlite, SqliteRow, SqliteValueRef};
4445
use crate::db::migrations::ColumnTypeMapper;
45-
use crate::error::impl_into_cot_error;
4646

4747
const ERROR_PREFIX: &str = "database error:";
4848
/// An error that can occur when interacting with the database.

cot/src/email.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ use std::sync::Arc;
3232

3333
use cot::config::{EmailConfig, EmailTransportTypeConfig};
3434
use cot::email::transport::smtp::Smtp;
35+
use cot_core::error::impl_into_cot_error;
3536
use derive_builder::Builder;
3637
use derive_more::with_trait::Debug;
3738
use thiserror::Error;
3839
use transport::{BoxedTransport, Transport};
3940

4041
use crate::email::transport::TransportError;
4142
use crate::email::transport::console::Console;
42-
use crate::error::impl_into_cot_error;
4343
const ERROR_PREFIX: &str = "email message build error:";
4444

4545
/// Represents errors that can occur when sending an email.

0 commit comments

Comments
 (0)