Skip to content

Releases: ZihanType/predawn

0.9.0

11 Oct 08:53

Choose a tag to compare

Breaking

  • breaking: refactor error handling:
    • change the definition of the status_codes method on the ResponseError trait from fn status_codes() -> BTreeSet<StatusCode> to fn status_codes(codes: &mut BTreeSet<StatusCode>).
    • replace dep snafu with thiserror.
    • refactor all ResponseError trait implementations.
    • change fn error_chain(&self) -> &[&'static str] method on the Error struct to fn error_stack(&self) -> &[Box<str>].
    • add ErrorExt trait, and change the Error trait in super traits of ResponseError to ErrorExt trait.
  • breaking: add required method title to ToSchema trait.
  • breaking: rename method ToSchema::name to ToSchema::key.
  • breaking: remove the impl From<LogLevel> for tracing::Level implementation.

Feat

  • feat: add EventStream::new method.
  • feat: add LogLevel::Off variant to disable logging.
  • feat: add as_{log, tracing}_level{_filter} methods to LogLevel for conversion to log and tracing log levels.
  • feat: rename the handler attribute in the controller attribute macro to endpoint to avoid rust-analyzer introducing the predawn::handler module when code completion occurs.

Fix

  • fix: invalid default comment in KeepAlive used by EventStream.

Chore

  • chore: avoid cloning Arc during deserialization of Path.
  • chore: update tower-http to 0.6.
  • chore: update tokio-tungstenite to 0.24.
  • chore: add comments for internal implementation details.
  • chore: re-export http crate.
  • chore: handle InsertError in one place.

Predawn Sea ORM

  • [predawn-sea-orm] breaking: rename Connection struct to DataSource.
  • [predawn-sea-orm] breaking: change the definition of the Error enum.
  • [predawn-sea-orm] breaking: commit and rollback methods take parameters of type Transaction.
  • [predawn-sea-orm] breaking: rename new_txn method to create_txn.
  • [predawn-sea-orm] feat: support nested transaction.
  • [predawn-sea-orm] feat: expose task-local variable DATA_SOURCES for easy customization of transaction management.

0.8.0

14 Sep 06:47

Choose a tag to compare

  • breaking: rename types: Multipart to Upload, Attachment to Download, AttachmentError to DownloadError. rename method: Attachment::new to Download::attachment.

  • breaking: refactor ParseField trait to support parsing multiple fields into [T; N] arrays.

  • breaking: rename MultipartError::RepeatedField variant to MultipartError::DuplicateField.

  • breaking: add MultipartError::IncorrectNumberOfFields variant.

  • breaking: add components parameter to associated function schema of ToSchema trait.

  • breaking: move predawn::media_type::InvalidContentType to predawn::response_error::InvalidContentType.

  • breaking: rename the wrappers method on the Error type to error_chain.

  • breaking: delete DownloadError enum.

  • breaking: change the <Download<T> as IntoResponse>::Error type from DownloadError<T::Error> to Either<T::Error, InvalidContentDisposition>.

  • breaking: change the return type of ToHeaderValue::to_header_value from Option<Result<HeaderValue, InvalidHeaderValue>> to MaybeHeaderValue.

  • breaking: refactor ParseField trait.

  • breaking: add parameter map: &mut AnyMap to init_logger method in Hooks trait.

  • breaking: change Environment::Custom(String) to Environment::Custom(Box<str>).

  • breaking: change impl From<&Config> for {Logger, OpenAPI, Server, DataSources}Config to {Logger, OpenAPI, Server, DataSources}Config::new(&Config).

  • breaking: remove the DataStream type and replace it with http_body_util::BodyDataStream.

  • breaking: parameter type of the from_request_head function in the FromRequestHead trait changed from &Head to &mut Head.

  • breaking: parameter type of the from_request function in the FromRequest trait changed from &Head to &mut Head.

  • breaking: change the return type of the status_codes function in the ResponseError trait from HashSet<...> to BTreeSet<...>.

  • breaking: change the parameter of the following methods from components: &mut Components to schemas: &mut BTreeMap<String, Schema>:

    1. ToSchema::schema
    2. ToSchema::schema_ref
    3. ToSchema::schema_ref_box
    4. ToParameters::parameters
    5. ApiRequestHead::parameters
    6. ApiRequest::parameters
    7. ApiRequest::request_body
    8. ApiResponse::responses
    9. ResponseError::responses
    10. SingleMediaType::media_type
    11. MultiRequestMediaType::content
    12. MultiResponseMediaType::content
    13. SingleResponse::response
    14. MultiResponse::responses
  • feat: add an associated function name to the ToSchema trait with a default implementation.

  • feat: add a title field to the schema generated by the ToSchema derived macro.

  • feat: add an associated function schema_ref_box to ToSchema trait.

  • feat: add Tag derive macro and Tag trait.

  • feat: add tags parameter for controller and handler attribute macros.

  • feat: comments on handler, ToSchema, ToParameter attribute macros can be parsed as descriptions in OpenAPI.

  • feat: add support for Redoc, Scalar, and OpenAPI Explorer.

  • feat: add openapi_security_requirements and openapi_security_schemes functions to Hooks trait.

  • feat: add SecurityScheme derive macro and SecurityScheme trait.

  • feat: add security parameter for controller and handler attribute macros.

  • feat: parses document comments for MultiRequestMediaType, MultiResponseMediaType, Multipart, and SingleResponse derive macros into OpenAPI's description.

  • feat: add TypedHeader extractor.

  • feat: add InvalidContentDisposition struct.

  • feat: add MaybeHeaderValue enum.

  • feat: add InvalidHeaderValue struct.

  • feat: add flatten attribute for ToParameter and ToSchema derive macros that can be placed on fields.

  • feat: add default attribute for fields of struct annotated by derive macro for Multipart, ToSchema, ToParameters.

  • feat: the ToSchema derive macro can be used on enum.

  • feat: the ToSchema derive macro can generate schema for nested types.

  • feat: add AnyMap struct.

  • feat: support WebSocket.

  • feat: support Server-Sent Events.

  • fix: doc test failure in predawn-macro crate.

  • fix: all requests shared a single data sources context.

  • fix: if some field has a default attribute, it will be not required in the OpenAPI schema.

  • change: allow the paths and methods arguments in the handler attribute macro to be empty, like this #[handler(paths = [], methods = [])].

  • change: add parameter to the Download::inline function.

  • change: schema for JosnField<T> is totally same as for T.

  • change: move the check for path uniqueness to the create_app function.

  • change: clean up handle_conn implementation.

  • change: remove panic! in the expansion of the SingleResponse derive macro.

  • change: wrap errors from serialize and deserialize query and form with serde_path_to_error::Error<...>.

  • chore: add default feature macro to predawn crate.

  • chore: replace get_provider method with contains_provider method.

  • chore: change the methods called when inserting a schema to Components.

  • chore: remove preserve_order feature of serde_json dependency.

  • chore: change the type of method parameter for internal Controller trait.

  • chore: change tokio::fs::read function to std::fs::read function.

  • chore: add default-schema-tab property to <openapi-explorer>.

  • chore: reducing one clone method call.

  • chore: remove once_cell dep.

  • chore: upgrade sea-orm dep to 1.

  • chore: change the log level from trace to info when the server closing.

  • chore: update tower to 0.5.

  • chore: relax the ResponseBody::new method generic constraint.

  • chore: replace part of BTreeMap with IndexMap in the internal implementation.

  • chore: change the internal implementation.

  • chore: make the code generated by the controller attribute macro more readable.

predawn-sea-orm

03 May 14:24

Choose a tag to compare

Add predawn-sea-ormcrate, see example for usage.

0.7.0

16 Apr 17:33

Choose a tag to compare

  • breaking: move predawn::to_header_value::ToHeaderValue to predawn::response::ToHeaderValue.
  • breaking: remove JsonDataError and JsonSyntaxError variants from ReadJsonError, add DeserializeJsonError variant.
  • breaking: replace all HashMap<Method, DynHandler>s with IndexMap<Method, DynHandler>s.
  • feat: add Multipart reqeust support.
  • feat: add Attachment response support.
  • feat: add shutdown_signal function.
  • feat: add DeserializeJsonError error.
  • fix: change property names in Schema of SystemTime and Duration.

0.6.0

09 Apr 16:40

Choose a tag to compare

  • breaking: change predawn::extract::{path::Path, query::Query} to predawn::extract::{Path, Query}.
  • breaking: change predawn::middleware::{tower_compat::TowerLayerCompatExt, tracing::Tracing} to predawn::middleware::{TowerLayerCompatExt, Tracing}.
  • breaking: change predawn::payload::{form::Form, json::Json} to predawn::payload::{Form, Json}.
  • breaking: change the type of the middleware parameter in the controller and handler attribute macros from fn(impl Handler, &mut Context) -> impl Handler to fn(&mut Context, impl Handler) -> impl Handler.
  • breaking: move ReadBytesError and ReadStringError to predawn_core::response_error module.
  • breaking: change ReadBytesError::LengthLimitError(LengthLimitError) to ReadBytesError::RequestBodyLimitError(RequestBodyLimitError).
  • breaking: move MethodNotAllowedError, MatchError, QueryError, PathError, ReadFormError, WriteFormError, ReadJsonError, WriteJsonError to predawn::response_error module.
  • breaking: rename the got field in PathError::WrongNumberOfParameters { got, .. } to actual.
  • breaking: change the type of the key and value fields in PathError::ParseErrorAtKey { key, value, .. } from String to Arc<str>.
  • breaking: change the type of the key field in PathError::InvalidUtf8InPathParam { key, .. } from String to Arc<str>.
  • breaking: change type Vec<&'static str> to Box<[&'static str]> in the return type of the Error::downcast method.
  • breaking: change type Vec<&'static str> to Box<[&'static str]> in generics of HandlerExt::catch_error method.
  • breaking: change field types in RapiDoc and SwaggerUI structs from String to Arc<str>.
  • breaking: remove unnacessary Environment::set_env method.
  • breaking: remove unnacessary impl FromStr for Environment implementation.
  • breaking: change the type of the actual field in the InvalidContentType struct from String to Box<str>.
  • breaking: change the type of the routes field in the Router struct from Vec<(Box<str>, Vec<Method>)> to Vec<(Box<str>, Box<[Method]>)>.
  • breaking: rename RequestBodyLimit struct to BodyLimit.
  • breaking: rename predawn_core::request::DEFAULT_REQUEST_BODY_LIMIT to predawn_core::request::DEFAULT_BODY_LIMIT.
  • feat: add RequestBodyLimitError error.
  • feat: add body_limit field to Head struct.
  • feat: add RequestBodyLimit middleware.
  • feat: add Head::content_length method.
  • change: expose all structs under the predawn::handler module.
  • change: enhance compatibility with tower.

0.5.0

02 Apr 16:35

Choose a tag to compare

  • breaking: use AFIT instead of async_trait on the Handler trait., reference to poem.
  • breaking: use AFIT instead of async_trait on the FromRequest trait., reference to poem.
  • breaking: use AFIT instead of async_trait on the FromRequestHead trait., reference to poem.
  • breaking: split the FromRequestHead trait into FromRequestHead trait and ApiRequestHead trait.
  • breaking: split the FromRequest trait into FromRequest trait and ApiRequest trait.
  • breaking: split the IntoResponse trait into IntoResponse trait and ApiResponse trait.
  • breaking: split the SingleMediaType trait into SingleMediaType trait and MediaType trait.
  • breaking: all Arc<dyn Handler> types are now DynHandler.
  • breaking: change the generic bounds of the HandlerExt::inspect_error method.
  • breaking: change the generic bounds of the HandlerExt::catch_error method.
  • breaking: add const generics to InvalidContentType.
  • breaking: change Error::downcast method return type from Result<T, Self> to Result<(Response, T, Vec<&'static str>), Self>.
  • breaking: change the name of the Error::source_type_name method from source_type_name to wrappers and the return type from &'static str to &[&'static str].
  • breaking: change the parameter name status_code to status in the MultiResponseMediaType attribute macro.
  • feat: use rudi crate's new feature to change the constructor methods for types LoggerConfig, OpenAPIConfig, ServerConfig to From::<&Config>::from.
  • feat: add DynHandler struct.
  • feat: add HandlerExt::with_if method.
  • feat: add SingleResponse and MultiResponse attribute macros.
  • feat: add define_from_request_error and define_into_response_error declarative macros to make it easier to define the error type when using the MultiRequestMediaType, MultiResponseMediaType, MultiResponse attribute macros.
  • feat: add ToHeaderValue trait.
  • change: in release mode, the Environment::resolve_from_env method returns Environment::Prod if no environment variables are found.
  • fix: the parameter status of the MultiResponseMediaType attribute macro shall be optional.
  • docs: update links.
  • docs: change the examples in the MultiRequestMediaType and MultiResponseMediaType attribute macros from defining error types manually to defining errors with the define_from_request_error and define_into_response_error declarative macros.
  • docs: add a simpler example to README.md.
  • chore: simplify Config::from_folder method.
  • chore: change the parameter types of the Controller::insert_routes method.
  • chore: change Tracing middleware log format.
  • chore: use the new tokio crate feature to change the use of Arc<Sender> to Sender.
  • chore: add Sized bound to ResponseError trait.
  • chore: rename controller/mod.rs to controller.rs.
  • chore: simplify trait implementations.

0.4.0

23 Mar 16:23

Choose a tag to compare

  • breaking: remove Error::downcast_mut method.
  • breaking: rename Error::as_status method to Error::status.
  • breaking: rename Error::as_response method to Error::response.
  • breaking: rename Error::inner_type_name method to Error::source_type_name.
  • breaking: change the return type of the Head::local_addr method from SocketAddr to LocalAddr.
  • breaking: change the return type of the Head::remote_addr method from SocketAddr to RemoteAddr.
  • breaking: change the return type of the Head::original_uri method from &Uri to &OriginalUri.
  • breaking: remove predawn_macro::method::Method::connect because there is no connect method in the OpenAPI Spec.
  • feat: add impl From<(StatusCode, BoxError)> for Error implementation.
  • fix: in the code expanded by the controller attribute macro, the last parameter is placed first.
  • chore: change the style of asynchronous method definitions in the Hooks trait.
  • chore: remove ..Default::default() in derive macros.
  • chore: update dep reqwest to 0.12.
  • chore: remove unnecessary helper function.

0.3.0

15 Mar 10:08

Choose a tag to compare

  • break: change the type of associated constant STATUS_CODE of SingleResponse trait from StatusCode to u16.
  • break: upgrade dependency matchit to 0.8, change /:a to /{a} and /*a to /{*a} in all paths.
  • break: add a tower-compat feature to the predawn::tower_compat module, which is not enabled by default.
  • break: change the type of the fields representing path in each of the ServerConfig and OpenAPIConfig structs from String to NormalizedPath.
  • break: add cx: &mut Context parameter to Hooks::openapi_info method.
  • break: replace predawn::openapi::ToParameters with predawn::ToParameters.
  • break: replace predawn::media_type::MultiRequestMediaType with predawn::MultiRequestMediaType.
  • break: replace predawn::media_type::MultiResponseMediaType with predawn::MultiResponseMediaType.
  • break: replace predawn::response::MultiResponse with predawn::MultiResponse.
  • break: replace predawn::response::SingleResponse with predawn::SingleResponse.
  • feat: change visibility of function app::create_app from pub(crate) to pub.
  • feat: add InvalidContentType struct, MultiRequestMediaType and MultiResponseMediaType derive macros.
  • feat: add Hooks::openapi_servers method.
  • improve: add log when loading config file.
  • improve: add error message context for when route insertion fails.
  • change: manual implementation of Serialize and Deserialize traits for NormalizedPath.
  • chore: replace ::openapiv3 with crate::openapi wherever it appears in predawn-core crate.
  • chore: change predawn::__internal::predawn_core to predawn in the code of macro expanded in the predawn-macro crate.
  • chore: upgrade dep sync_wrapper to 1.
  • chore: remove workspace = true from path dev-dependencies to make it easier to publish.

0.2.0

07 Mar 08:22

Choose a tag to compare

  • breaking:

    change Hooks::add_middlewares<H: Handler>(router: H, cx: &mut Context) -> impl Handler

    to Hooks::before_run<H: Handler>(cx: Context, router: H) -> (Context, impl Handler).

  • breaking: change the type of the env parameter in the Config::{load, from_folder} methods from Environment to &Environment.

  • breaking: change the Hooks::load_config method by adding the parameter env: &Environment.

  • breaking: change the Hooks::create_context method by adding the parameter env: Environment.

  • breaking: change the Hooks::start_server method by changing the order of parameters from router, cx to cx, router.

  • feat: add an end-to-end testing struct TestClient.

  • chore: refactor app::run_app function.

  • feat: add 4 implementations of the FromRequestHead trait: &OriginalUri, OriginalUri, LocalAddr, RemoteAddr.