Tide v0.15.0 Release Notes
Release Date: 2020-11-13 // over 4 years ago-
This patch adds
Server::bind
,SessionMiddleware::with_cookie_domain
, and a new optional cookies feature.Server::bind
Tide v0.15.0 introduces a new way to start servers:
Server::bind
. This enables separatining "open the socket" from "start accepting connections" whichServer::listen
does for you in a single call.๐ This was introduced as a way to enable users to log messages after ports were successfully opened. But it can also be used to synchronize server initialization. For example: your application may want to connect to a database, a cache, and open an HTTP connection. With
Server::bind
you can start the connection, but wait to handle inbound traffic until all other components of the server have started up.๐ When
Server::bind
is called, it returns an instance ofListener
which is able to return information on all ports that are being listened on. By defaultServer::listen
logs these out, but when manually callingServer::bind
you get control on how to log this info.๐ For now
ListenInfo
only includes a few basics such as the address that's being listened on, and whether the connection is encrypted. But as we seek to stabilize and integratetide-rustls
intotide
, we may include more info on the encryption settings. And perhaps in the future we'll include more information on the server's routes too. But for now this serves as an entry point for all that.use tide::prelude::\*;let mut app = tide::new(); app.at("/").get(|\_| async { Ok("Hello, world!") });let mut listener = app.bind("127.0.0.1:8080").await?;for info in listener.info().iter() { println!("Server listening on {}", info); } listener.accept().await?;
SessionMiddleware::with_cookie_domain
Our session middleware now supports a
with_cookie_domain
method to scope a cookie to a specific domain. We already support various cookie options when constructing the session middleware, and now we support scoping the domain as well.let SECRET = b"please do not hardcode your secret";let mut app = tide::new(); app.with(SessionMiddleware::new(MemoryStore::new(), SECRET) .with\_cookie\_name("custom.cookie.name") .with\_cookie\_path("/some/path") .with\_cookie\_domain("www.rust-lang.org") // This is new. .with\_same\_site\_policy(SameSite::Lax) .with\_session\_ttl(Some(Duration::from\_secs(1))) .without\_save\_unchanged(), );
http-types
typed headers๐ We've been doing a lot of work on typed headers through
http-types
, which is the HTTP library underpinning both tide and surf. We're getting close to being done implementing all of the specced HTTP Headers, and will then move to integrate them more closely into Tide. You can find the release notes forhttp-types
here.โ Added
- โ Add
Server::bind
#740 - Add
with_cookie_domain
method toSessionMiddleware
#730 - โ Add an optional cookies feature #717
๐ Fixed
Internal
- ๐ Lints #704
- โ Add
Previous changes from v0.14.0
-
๐ Documentation
๐ This patch introduces a several feature flags to opt-out of dependencies, a reworked rustdoc landing page, and a variety of bug fixes. Over the past few months we've been hard at work on Surf v2.0.0, and have made a lot of progress on
http-types
' typed headers. We hope to start bringing some of this work over into Tide soon.Behind the scenes we're also hard at work at improving our processes. Both Tide and the wider http-rs project have really taken off, and our biggest challenge in ensuring we correctly prioritize, communicate, and empower people who want to get involved. We don't have specifics we can share yet, but it's something we're actively working on with the team. Because as Tide and http-rs grow, so must our processes.
โ Added
- Implement
Endpoint
forBox<dyn Endpoint>
#710 - โ Add a
http_client::HttpClient
implementation fortide::Server
#697 - Introduce a
logger
feature to optionally disable thefemme
dependency #693 - โ Add
Server::state
method #675
๐ Changed
- โ Remove parsing from
Request::param
#709 - ๐ Rework landing docs #708
- โ Log: display client error messages when possible as warnings #691
- ๐ Make all listeners conditional on
h1-server
feature #678
๐ Fixed
- ๐จ Logger: properly print debug from errors #721
- ๐ Fix missing as_ref that caused boxed endpoints to enter an infinite loop #711
- ๐ Bugfix, route prefix was always set to false after calling nest #702
- ๐ Fix a broken documentation link #685
Internal
- โฌ๏ธ Upgrade deps #722
- ๐ CI, src: run clippy on nightly, apply fixes #707
- โก๏ธ Update to latest Surf alpha in tests #706
- ๐ Fix .github #705
- โ Add driftwood to middleware section #692
- ๐จ Refactor README #683
- Main branch renamed to
main
#679 - โฌ๏ธ Bump version number in README.md #672
- โ Add community resources to readme instead of wiki #668
- Implement