Skip to content

Commit

Permalink
chore(actix-settings): prepare release 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robjtede committed Aug 7, 2024
1 parent 0c0d13b commit 50d2fee
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
14 changes: 7 additions & 7 deletions actix-settings/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

## Unreleased

- Add new feature named `openssl` for TLS settings using `OpenSSL` dependency. [#380]
- Add new function `settings::tls::Tls::get_ssl_acceptor_builder()` to build `openssl::ssl::SslAcceptorBuilder`. [#380]
- Implement TLS logic for `ApplySettings<S>::try_apply_settings()`. [#380]
- Add `openssl` dependency;
- Minimum supported Rust version (MSRV) is now 1.75.
- `ApplySettings<S>::apply_settings()` is deprecated; `ApplySettings<S>::try_apply_settings()` should be preferred. [#380]
## 0.8.0

[#380]: https://github.com/actix/actix-extras/pull/380
- Add `openssl` crate feature for TLS settings using OpenSSL.
- Add `ApplySettings::try_apply_settings()`.
- Implement TLS logic for `ApplySettings::try_apply_settings()`.
- Add `Tls::get_ssl_acceptor_builder()` function to build `openssl::ssl::SslAcceptorBuilder`.
- Deprecate `ApplySettings::apply_settings()`.
- Minimum supported Rust version (MSRV) is now 1.75.

## 0.7.1

Expand Down
2 changes: 1 addition & 1 deletion actix-settings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-settings"
version = "0.7.1"
version = "0.8.0"
authors = [
"Joey Ezechiels <[email protected]>",
"Rob Ede <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions actix-settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<!-- prettier-ignore-start -->

[![crates.io](https://img.shields.io/crates/v/actix-settings?label=latest)](https://crates.io/crates/actix-settings)
[![Documentation](https://docs.rs/actix-settings/badge.svg?version=0.7.1)](https://docs.rs/actix-settings/0.7.1)
[![Documentation](https://docs.rs/actix-settings/badge.svg?version=0.8.0)](https://docs.rs/actix-settings/0.8.0)
![Apache 2.0 or MIT licensed](https://img.shields.io/crates/l/actix-settings)
[![Dependency Status](https://deps.rs/crate/actix-settings/0.7.1/status.svg)](https://deps.rs/crate/actix-settings/0.7.1)
[![Dependency Status](https://deps.rs/crate/actix-settings/0.8.0/status.svg)](https://deps.rs/crate/actix-settings/0.8.0)

<!-- prettier-ignore-end -->

Expand Down
23 changes: 19 additions & 4 deletions actix-settings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,26 @@ where

/// Extension trait for applying parsed settings to the server object.
pub trait ApplySettings<S>: Sized {
/// Apply some settings object value to `self`.
#[deprecated = "Prefer `try_apply_settings`."]
fn apply_settings(self, settings: &S) -> Self;
/// Applies some settings object value to `self`.
///
/// The default implementation calls [`try_apply_settings()`].
///
/// # Panics
///
/// May panic if settings are invalid or cannot be applied.
///
/// [`try_apply_settings()`]: ApplySettings::try_apply_settings().
#[deprecated = "Prefer `try_apply_settings()`."]
fn apply_settings(self, settings: &S) -> Self {
self.try_apply_settings(settings)
.expect("Could not apply settings")
}

/// Apply some settings object value to `self`.
/// Applies some settings object value to `self`.
///
/// # Errors
///
/// May return error if settings are invalid or cannot be applied.
fn try_apply_settings(self, settings: &S) -> AsResult<Self>;
}

Expand Down
24 changes: 10 additions & 14 deletions actix-settings/src/settings/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,31 @@ pub struct Tls {
}

impl Tls {
/// Generates an [`SslAcceptorBuilder`] with its settings. It is often used for the following method
/// [`actix_web::server::HttpServer::bind_openssl`].
/// Returns an [`SslAcceptorBuilder`] with the configured settings.
///
/// The result is often used with [`actix_web::HttpServer::bind_openssl()`].
///
/// # Example
/// ```no_run
/// use actix_settings::{ApplySettings, Settings};
/// use actix_web::{get, App, HttpServer, Responder};
///
/// #[get("/")]
/// async fn index() -> impl Responder {
/// "Hello."
/// }
/// ```no_run
/// use std::io;
/// use actix_settings::{ApplySettings as _, Settings};
/// use actix_web::{get, web, App, HttpServer, Responder};
///
/// #[actix_web::main]
/// async fn main() -> std::io::Result<()> {
/// async fn main() -> io::Result<()> {
/// let settings = Settings::from_default_template();
///
/// HttpServer::new(|| {
/// App::new()
/// .service(index)
/// App::new().service(web::to(|| { "Hello, World!" }))
/// })

Check failure on line 41 in actix-settings/src/settings/tls.rs

View workflow job for this annotation

GitHub Actions / coverage

the trait bound `{closure@actix-settings/src/settings/tls.rs:13:36: 13:38}: Handler<_>` is not satisfied

Check failure on line 41 in actix-settings/src/settings/tls.rs

View workflow job for this annotation

GitHub Actions / coverage

the trait bound `Route: HttpServiceFactory` is not satisfied

Check failure on line 41 in actix-settings/src/settings/tls.rs

View workflow job for this annotation

GitHub Actions / Documentation Tests

the trait bound `{closure@actix-settings/src/settings/tls.rs:13:36: 13:38}: Handler<_>` is not satisfied

Check failure on line 41 in actix-settings/src/settings/tls.rs

View workflow job for this annotation

GitHub Actions / Documentation Tests

the trait bound `Route: HttpServiceFactory` is not satisfied
/// .try_apply_settings(&settings)?
/// .bind(("127.0.0.1", 8080))?
/// .bind_openssl(("127.0.0.1", 8081), settings.actix.tls.get_ssl_acceptor_builder()?)?
/// .bind_openssl(("127.0.0.1", 8443), settings.actix.tls.get_ssl_acceptor_builder()?)?
/// .run()
/// .await
/// }
/// ```
#[allow(rustdoc::broken_intra_doc_links)]
pub fn get_ssl_acceptor_builder(&self) -> AsResult<SslAcceptorBuilder> {
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls())?;
builder.set_certificate_chain_file(&self.certificate)?;
Expand Down

0 comments on commit 50d2fee

Please sign in to comment.