Tide v0.15.0 Release Notes

Release Date: 2020-11-13 // over 3 years ago
  • This patch adds Server::bind, SessionMiddleware::with_cookie_domain, and a new optional cookies feature.


    Tide v0.15.0 introduces a new way to start servers: Server::bind. This enables separatining "open the socket" from "start accepting connections" which Server::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 of Listener which is able to return information on all ports that are being listened on. By default Server::listen logs these out, but when manually calling Server::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 integrate tide-rustls into tide, 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("").await?;for info in listener.info().iter() { println!("Server listening on {}", info); } listener.accept().await?;


    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 for http-types here.

    โž• Added

    • โž• Add Server::bind #740
    • Add with_cookie_domain method to SessionMiddleware #730
    • โž• Add an optional cookies feature #717

    ๐Ÿ›  Fixed

    • ๐Ÿ›  Fix param documentation #737
    • ๐Ÿ›  Fix port in README #732


    • ๐Ÿ‘• Lints #704

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 for Box<dyn Endpoint> #710
    • โž• Add a http_client::HttpClient implementation for tide::Server #697
    • Introduce a logger feature to optionally disable the femme 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


    • โฌ†๏ธ 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