All Versions
22
Latest Version
Avg Release Cycle
32 days
Latest Release
1250 days ago

Changelog History
Page 1

  • v0.15.0 Changes

    November 13, 2020

    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" 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("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 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

    Internal

    • ๐Ÿ‘• Lints #704
  • v0.14.0 Changes

    October 16, 2020

    ๐Ÿ“š 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

    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
  • v0.13.0 Changes

    July 31, 2020

    ๐Ÿ“„ Docs

    ๐Ÿš€ This release introduces first-class support for sessions, fixes a
    0๏ธโƒฃ long-standing bug with our default middleware, clarifies our stability
    guarantees, and renamed the API to register middleware through.

    Sessions

    ๐Ÿ‘ We're excited to announce initial support for sessions in Tide. This feature
    enables Tide applications to associate multiple separate requests as
    ๐Ÿ— belonging to the same origin. Which is a pre-requisite to build common
    ๐ŸŒ web-app features such as user accounts, multi-request transactions, and
    channels.

    ๐Ÿ— Tide sessions are generic over backend stores and signing strategy. It builds
    ๐Ÿš€ on the newly released async-session
    ๐Ÿ“„ 2.0.0
    library, which is a set of common
    traits that types that make up a session. But beyond that, much of it is
    implementation specific.

    0๏ธโƒฃ Tide ships with a memory and cookie store by default. However we have
    also published several convenient session store implementations for common
    databases, providing a nice selection to choose from:

    Using "Redis" as the backing session store for Tide is as easy as writing 3
    lines and including a dependency in your Cargo.toml:

    use async\_redis\_session::RedisSessionStore;use tide::sessions::SessionMiddleware;use tide::{Redirect, Request}; #[async\_std::main]async fn main() -\> tide::Result\<()\> { let mut app = tide::new(); // Create a Redis-backed session store and use it in the applet store = RedisSessionStore::new("redis://127.0.0.1:6379")?; let secret = std::env::var("SESSION\_SECRET").unwrap(); app.with(SessionMiddleware::new(store, secret.as\_bytes())); app.at("/").get(|mut req: Request\<()\>| async move { // Store a counter in the session; increment it by one on each visitlet session = req.session\_mut(); let visits: usize = session.get("visits").unwrap\_or\_default(); session.insert("visits", visits + 1).unwrap(); // Render a page that shows the number of requests made in the sessionlet visits: usize = req.session().get("visits").unwrap(); Ok(format!("you have visited this website {} times", visits)) }); // Close the current session app.at("/reset").get(|mut req: Request\<()\>| async move { req.session\_mut().destroy(); Ok(Redirect::new("/")) }); // Start the server app.listen("127.0.0.1:8080").await?; Ok(()) }
    

    It's still early for Tide sessions. But we're incredibly excited for how
    convenient it already is, and excited for the possibilities this will enable!

    Renaming Server::middleware to Server::with

    This patch renames Server::middleware to Server::with in order to
    streamline much of the middleware APIs.

    // After this patchlet mut app = tide::new(); app.with(MyMiddleware::new()); app.at("/").get(|\_| async move { Ok("hello chashu") }); app.listen("localhost:8080").await?;// Before this patchlet mut app = tide::new(); app.middleware(MyMiddleware::new()); app.at("/").get(|\_| async move { Ok("hello chashu") }); app.listen("localhost:8080").await?;
    

    A small change, but ever so convenient.

    ๐ŸŒฒ No more duplicate log messages

    0๏ธโƒฃ Ever since we introduced application nesting we've had issues with default
    ๐Ÿ›  middleware running twice. This patch fixes that for our logging middleware in
    two ways:

    0๏ธโƒฃ 1. We've introduced a logger Cargo feature to disable the default logging middleware #661

    1. We now track calls to the logger inside the state map to ensure
      it's only called once per app #662

    โšก๏ธ There may be room to optimize this further in the future, and perhaps extend
    the same mechanisms to work for more built-in middleware. But for now this
    patch resolves the most common issues people were reporting.

    Clarification on stability

    ๐Ÿš€ Tide has been deployed to production in many places: independent authors
    ๐Ÿ— taking control of their publishing pipelines, software professionals building
    internal tooling, and enterprises running it in key parts of their
    infrastructure.

    ๐Ÿš€ In past Tide releases shipped with a warning that actively recommended
    ๐Ÿš‘ against using it in any critical path. However we've chosen to no longer
    ๐Ÿš€ include that warning starting this release. Much of the work at the protocol
    layer and below has completed, and we've received positive reports on how it
    performs.

    For the foreseable future Tide will remain on the 0.x.x semver range. While
    we're confident in our foundations, we want to keep iterating on the API.
    ๐Ÿš€ Once we find that work has slowed down we may decide when to release a 1.0.0
    ๐Ÿš€ release.

    โž• Added

    • โž• Added From<StatusCode> for Response #650
    • โž• Added a feature-flag to disable the default logger middleware #661
    • โž• Added impl Into<Request> for http_types::Request #670

    ๐Ÿ”„ Changes

    • ๐Ÿ“‡ Rename Server::middleware to Server::with #666
    • โฌ†๏ธ Relax Sync bound on Fut required on sse::upgrade #647
    • Consistency improvements for examples #651
    • โฌ†๏ธ Bumped version number in docs #652
    • โž• Add enable logging in README example #657
    • โœ‚ Remove "experimental" warning #667

    ๐Ÿ›  Fixes

    • ๐ŸŒฒ Guarantee the log middleware is only run once per request #662

    Internal

    • โœ… Enable clippy for tests #655
    • Reorder deps in cargo.toml #658
  • v0.12.0 Changes

    July 17, 2020

    ๐Ÿ“„ Docs

    ๐Ÿš€ This release includes 35 PRs merged over the course of the last month. Most
    notably we've streamlined how errors are propagated inside middleware,
    ๐Ÿ‘ฏ introduced a new ResponseBuilder type, State must now be Clone, and we
    are introducing an extensible API for Server::listen.

    ResponseBuilder

    Returning responses from endpoints is often different from operating on
    response in middleware. In order to make it easier for people to author
    responses we're introducing tide::ResponseBuilder in this patch!

    ๐Ÿ— You can create a new response builder by calling Response::builder and
    passing it a status code. This enables writing some really concise endpoints:

    app.at("/").get(|\_| async { let res = Response::builder(203) .body(json!({ "hello": "cats!" })) .header("X-Nori", "me-ow") .header("X-Chashu", "meewwww"); Ok(res) })
    

    This sets Tide up really nicely for the future too; once we have async
    closures, and a resolution for Ok-wrapping (fingers crossed) this will be
    even more concise. We're excited for developments in the language!

    Server listen

    ๐Ÿ‘ Tide now supports extensions for
    App::listen. This patch introduces a new Listener trait that is
    implemented for std types such as TcpStream, SocketAddr and
    UnixStream. But can also be implemented by users of Tide to provide custom
    transports.

    ๐Ÿ‘ In particular, what this enables us to do is to start trialing TLS support in
    external crates. We'll soon have
    tide-rustls available as an external
    ๐Ÿ— crate that will enable building TLS-terminating Tide servers:

    let mut app = tide::new();let listener = TlsListener::build() .addrs("localhost:4433") .cert(cert) .key(key); app.listen(listener).await?;
    

    In addition we're shipping tide::listener::ConcurrentListener, a convenient
    constructor to have a single server respond to incoming requests from
    multiple transports. For example, some applications may want to listen on
    both IPv4 and IPv6. With ConcurrentListener that's possible:

    use std::net::{Ipv4Addr, Ipv6Addr};use tide::listener;let mut app = tide::new();let mut listener = listener::ConcurrentListener::new(); listener.add((Ipv4Addr::new(127, 0, 0, 1), 8000)); listener.add((Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 8000)); app.listen(listener).await?;
    

    ๐Ÿ‘ฏ State must be Clone

    One problem we had for a while was that when manually nesting or
    parallelizing applications, State would be wrapped in an Arc multiple
    times. In this patch we're solving that by providing people with more control
    ๐Ÿ‘ฏ around how State is shared by requiring State to implement Clone.

    ๐Ÿ‘ฏ In most existing applications State can be made Clone by manually
    wrapping it in an Arc::new. But it's also possible to wrap individual
    ๐Ÿ‘ฏ fields in an Arc and deriving `Clone for the whole struct, as we did in one
    of our examples:

    // Example state before this patch.struct State { users: RwLock\<Vec\<User\>\>, }// Example state after this patch.#[derive(Clone)]struct State { users: Arc\<RwLock\<Vec\<User\>\>\>, }
    

    There is no right answer how to structure State; but we wanted to enable
    people to factor it in the way that makes most sense for their applications.

    Using of async-trait

    We've migrated all of our traits to use async-trait. This should make it easier to author Middleware implementations. For convenience Tide re-exports as tide::utils::async_trait.

    ๐Ÿ”„ Changes in middleware error handling

    Before this patch, calling next().await? in middleware would return a
    Result<Response>. The idea was that the Err variant could freely be
    thrown up the middleware stack, and transformed into a Response at the top
    of the stack. However in practice this didn't turn out great: middleware such
    as CORS needed to manipulate the Err path to ensure the right headers were
    set. And we didn't provide an interface for this.

    So instead this patch changes the way we handle errors in middleware. We
    still enable ? to be used inside middleware, but between each middleware we
    convert Result<Response, tide::Error> into a Response, and if an error
    occurred, we populate the newly introduced Response::error field.

    This means that middleware can always assume there is a valid Response
    coming through, and no longer needs to check both Ok and Err branch
    returned by next().await. An example:

    /// Before this patch: need to check both branches.async fn my\_middleware\<State\>(req: Request\<State\>, next: Next) -\> Result\<Response\> { println!("before"); match next().await { Err(err) =\> { println!("status code {}", err.status()); Err(err) } Ok(res) =\> { println!("status code {}", res.status()); Ok(res) } } }/// With this patch: there's only a single branch to operate on.async fn my\_middleware\<State\>(req: Request\<State\>, next: Next) -\> Result\<Response\> { println!("before"); let res = next().await; println!("status code {}", res.status()); Ok(res) }
    

    Note: neither of these examples will quite compile until we have async
    closures, but it serves to illustrate the point.

    โž• Added

    • โž• Add a doc example for Request::body_form #631
    • โž• Add a doc example for Request::query #630
    • โž• Add an upload example #619
    • โž• Add extensible entrypoint for Server::listen #610
    • โž• Add From<Body> for Response #584
    • โž• Add ResponseBuilder #580
    • โž• Add Response::error #570
    • โž• Add CORS headers to error responses #546

    ๐Ÿ”„ Changed

    • ๐Ÿ‘‰ Use async_trait to simplify async signatures #639
    • ๐ŸŒฒ Also include port and host in the log string #634
    • Don't panic on missing path param #615
    • Return a result from sse::Sender::send #598
    • ๐Ÿ˜Œ Relax the lifetime requirements of Server::at #597
    • In middleware Next::run now returns Response instead of Result<Response> #570
    • ๐Ÿ“‡ Rename tide::middleware to tide::utils #567
    • ๐Ÿ‘ฏ Require State to be Clone #644

    ๐Ÿ›  Fixed

    • ๐Ÿ‘‰ Make ServeDir return 404 if file does not exists #637
    • ๐Ÿ‘‰ Remove #[must_use] for Response::set_status() #612
    • Do not await the spawned task in Server::listen #606
    • ๐Ÿ‘ Allow route based function middlewares #600
    • ๐Ÿ›  Fix CORS middleware to retain cookies #599
    • Enable SSE senders to break out of loops #598
    • โœ‚ Remove extra unwraps from insert_header calls #590 #588 #583
    • Don't crash the server when there's a listen error #587
    • โž• Add CORS headers to error responses #546

    Internal

    • โœ‚ Remove executable mode from lib.rs #635
    • โšก๏ธ Update to async-sse 4.0.0 #632
    • ๐Ÿ›  Comment cleanup fixes #622
    • โž• Add clippy to ci #618
    • โช Restore .github docs #616
    • ๐Ÿ‘‰ Use route-recognizer 0.2 #607
    • โœ… Introduce an extension trait for testing servers #601
    • โšก๏ธ Update the readme with the latest versions #594
    • ๐Ÿ›  Fix tempfile usage in tests #592
    • ๐Ÿ›  Fix CI #589
    • โœ‚ Remove unnecessary moves from route handlers #581
  • v0.11.0 Changes

    June 12, 2020

    ๐Ÿš€ This patch introduces several minor features and fixes. This is a small release which picks up on some of the details we missed in our last few large releases.

    โž• Added

    • โž• Added Request::set_body #579
    • โž• Added impl From<Body> for Response #584

    ๐Ÿ”„ Changed

    • Response::set_status no longer takes and returns self #572

    ๐Ÿ›  Fixes

    • ๐Ÿ›  Fixed an issue with unwrap in SSE #588
    • ๐Ÿ›  Fixed an unwrap issue in Endpoint #590

    Internal

    • โœ‚ Delete the unmaintained CHANGELOG.md file #565
    • ๐Ÿ“‡ Renamed cx to req #582
    • ๐Ÿ›  Fix failing dependency on CI #589
    • ๐Ÿ‘‰ Use tide::Response interface in the sse endpoint #583
    • โœ‚ Remove unnecessary moves from route examples #581
  • v0.10.0 Changes

    June 05, 2020

    ๐Ÿ“„ Docs

    This release updates tide's Request and Response types to match http_types's Request and Response, a new Server::listen_unix method to listen on Unix Domain Sockets, and the ability to return json! literals directly from endpoints.

    โž• Added

    • โž• Added Server::listen_unix #531
    • โž• Added Request::peer_addr#530
    • โž• Added Request::local_addr#530
    • โž• Added Request::remote#537
    • โž• Added Request::host#537
    • โž• Added Request::header_mut#537
    • โž• Added Request::append_header#537
    • โž• Added Request::remove_header#537
    • โž• Added Request::iter#537
    • โž• Added Request::iter_mut#537
    • โž• Added Request::header_names#537
    • โž• Added Request::header_values#537
    • โž• Added Request::query#537
    • โž• Added Request::content_type#537
    • โž• Added warning about domain/path inconsistencies to remove_cookie #533
    • โž• Added an optional name method to Middleware #545
    • โž• Added AsRef/AsMut<Headers> for Request/Response #553
    • โž• Added Request::take_body #550
    • โž• Added Response::swap_body #562
    • โž• Added Response::iter #550
    • โž• Added Response::iter_mut #550
    • โž• Added Response::header_names #550
    • โž• Added Response::header_values #550
    • โž• Added Response::content_type #550
    • Added Response::set_content_type #550
    • โž• Added Response::header_mut #562
    • โž• Added tide::{After, Before} middleware constructors #556
    • โž• Added support for returning JSON literals from endpoints #523
    • Response::new now accepts u16 as well as StatusCode as arguments #562
    • โž• Added a new convert submodule which holds various conversion-related types, including serde #564

    ๐Ÿ”„ Changed

    • ๐Ÿ“‡ Renamed Request::uri to Request::url#537
    • Request::body_bytes now returns tide::Result #537
    • Request::body_string now returns tide::Result #537
    • Request::body_json now returns tide::Result #537
    • Request::body_form now returns tide::Result #537
    • Request::set_ext no longer takes and returns Self #537
    • ๐Ÿ‘‰ Use http_types::mime instead of the mime crate #536 -
    • Renamed Reponse::set_cookie to Response::insert_cookie #562
    • Various Response methods no longer return Self #562
    • Renamed Response::set_header to Response::insert_header #562
    • Renamed Reponse::set_ext to Response::insert_ext #562

    โœ‚ Removed

    • โœ‚ Removed Response::redirect in favor of tide::Redirect #562
    • Removed Response::{body_string, body_form, body_json, body} in favor of Response::set_body #562

    ๐Ÿ›  Fixed

    • โšก๏ธ Update docs from Request::local to Request::ext #539
    • Creating a middleware directly from a function is now possible again #545
    • ๐Ÿ›  Fixed wildcard tests #518

    Internal

    • ๐Ÿ›  Fix unix tests #552
    • โšก๏ธ Update http-types to 2.0.1 #537
    • โšก๏ธ Update async-sse to v3.0.0 #559
    • ๐Ÿ‘‰ Use query from http_types #555
    • ๐Ÿ›  Fix tests on master #560
    • โœ‚ Remove unused serde_qs dependency #569
    • โœ… Uncomment and fix response tests #516
  • v0.9.0 Changes

    May 23, 2020

    โšก๏ธ This patch updates http-types to 2.0.0, removes http-service in favor of
    Server::respond, and adds an all-new Redirect struct.

    http-types 2.0

    ๐Ÿš€ Read the http-types changelog for a full rundown of changes. But the biggest change for Tide is that working with headers in Tide is becoming a lot easier. To see all the changes in action, compare what it was like to compare a header with how it is now:

    // http-types 1.xassert\_eq!(req.header(&"X-Forwarded-For".parse().unwrap()), Some(&vec!["127.0.0.1".parse().unwrap()]));// http-types 2.xassert\_eq!(req.header["X-Forwarded-For"], "127.0.0.1");
    

    Constructing headers from string literals, comparing to string literals,
    using [] to access by name โ€” this should make it much easier to work with
    Tide!

    Server::respond

    http-service has been a tricky one. It originally served as a simplified wrapper around hyperium/hyper with a streaming Body type with the potential to abstract to other backends as well. But as we've evolved Tide and the http-rs ecosystem, we found http-service becoming more a hurdle than a help.

    โœ… In this patch we're removing http-service from Tide and introducing Server::respond as its replacement. This not only makes Tide easier to maintain, it makes it easier to use with any other backend than ever before. It also provides convenient way to unit test Tide apps as well:

    use tide::http::{self, Url, Method}; #[async\_std::test]async fn hello\_world() -\> tide::Result\<()\> { let mut app = tide::new(); app.at("/").get(|\_| async move { Ok("hello world")} ); let req = http::Request(Method::Get, Url::parse("http://computer.soup")?); let res = app.respond(req).await?; assert\_eq!(res.body\_string().await?, "hello world".to\_owned()); Ok(()) }
    

    Redirect

    In the past we introduced the redirect submodule which provided redirect endpoints. And Response::redirect* which provided methods to create redirects inside endpoints. In this patch we're removing those APIs in favor of tide::Redirect which can be used both to create new redirect endpoint, and be used inside existing endpoints to redirect:

    use tide::Redirect; #[async\_std::main]async fn main() -\> tide::Result\<()\> { let mut app = tide::new(); app.at("/fish").get(|\_| async move { Ok("yum") }); // Either create a redirect endpoint directly. app.at("/chashu").get(Redirect::new("/fish")); // Or redirect from inside an existing endpoint// enabling conditional redirects. app.at("/nori").get(|\_| async move { Redirect::new("/fish") }); app.listen("127.0.0.1:8080").await?; Ok(()) }
    

    Big thanks to @ethanboxx for introducing this pattern to Tide. We'll be looking to introduce this pattern to more APIs in the future.

    โž• Added

    • โž• Added Response::take_body #499
    • โž• Added Response::remove_header #508
    • โž• Added Server::respond #503
    • โž• Added @tirr-c as a co-author in Cargo.toml #507
    • โž• Added Response::from_res #466
    • โž• Added AsRef/AsMut impls to bridge Tide and http-types's req/res types #510
    • โž• Added Into<http_types::Request> for Request #510
    • โž• Added Response::header #515
    • โž• Added tide::log::start which starts a logger that pretty-prints in development and prints ndjson in release mode #495

    โœ‚ Removed

    • โœ‚ Removed http-service in favor of Server::respond #503
    • โœ‚ Removed the redirects directory in favor of tide::Redirect #513

    ๐Ÿ”„ Changed

    • Unified all redirect functionality into a single Redirect type #513
    • ๐Ÿ”Š The log middleware now logs time more accurately #517

    Internal

    • Apply clippy #526
    • โฌ†๏ธ Bump version number in README #489
    • ๐Ÿ”„ Changed file structure to match external exports #502
    • โœ‚ Remove unused dependencies #506
    • โž• Added a no-dev-deps check to CI #512
    • Fibonnacci example now uses Instant::elapsed #522
  • v0.8.1 Changes

    May 07, 2020

    ๐Ÿ“„ docs.rs

    ๐Ÿ›  This patch contains several bug fixes and doc tweaks.

    โž• Added

    • Route::serve_dir now applies some degree of mime guessing #461
    • โž• Added the "Tide Channels" post to the README #464
    • โž• Added documentation on Tide's default backend #467

    ๐Ÿ”„ Changed

    • โšก๏ธ Updated the crate version in the README #475

    ๐Ÿ›  Fixed

    • Check directory traversal attack without file system visit #473
    • ๐Ÿ“œ Correctly parse multiple values from the Cookie header #484
  • v0.8.0 Changes

    April 24, 2020

    ๐Ÿ“š API Documentation

    ๐Ÿš€ This patch introduces the use of the ? operator in Endpoints, initial support for Server-Sent Events, static file serving, and a new submodule hierarchy. This continues the integration of http-types we started in v0.7.0

    Fallible endpoints

    Tide now allows the use of ? in endpoints. Errors are automatically converted to tide::Error and have a status code of 500 assigned to them. Overriding status codes can be done through the use of the tide::Status trait which is included in the prelude.

    use async\_std::{fs, io};use tide::{Response, StatusCode}; #[async\_std::main]async fn main() -\> io::Result\<()\> { let mut app = tide::new(); app.at("/").get(|\_| async move { let mut res = Response::new(StatusCode::Ok); res.set\_body(fs::read("my\_file").await?); Ok(res) }); app.listen("localhost:8080").await?; Ok(()) }
    

    Server-Sent Events

    ๐Ÿš€ This release makes the first steps towards integrating channels in Tide. In this release we're introducing support for Server-Sent Events, unidirectional event streams that operate over HTTP. This can be used for implementing features such as live-reloading, or sending notifications.

    use tide::sse; #[async\_std::main]async fn main() -\> Result\<(), std::io::Error\> { let mut app = tide::new(); app.at("/sse").get(sse::endpoint(|\_req, sender| async move { sender.send("fruit", "banana", None).await; sender.send("fruit", "apple", None).await; Ok(()) })); app.listen("localhost:8080").await?; Ok(()) }
    

    ๐Ÿ’ป Connecting to the stream can be done using async-sse or from the browser:

    var sse = new EventSource('/sse');sse.on("message", (ev) =\> console.log(ev));
    

    In the future we may expand on these APIs to allow other endpoints to send messages on established channels, but in order to do so we need to implement session management first.

    Static file serving

    Tide is now able to serve static directories through the Route::serve_dir method. This allows mapping URLs to directories on disk:

    #[async\_std::main]async fn main() -\> Result\<(), std::io::Error\> { let mut app = tide::new(); app.at("/public/images").serve\_dir("images/")?; app.listen("127.0.0.1:8080").await?; Ok(()) }
    

    Revamped Hierarchy

    Tide has been changing a lot recently, and we've made changes to our submodules so we can keep up. We no longer have a singular middleware submodule and instead split them up by topic. This will allow us to continue to expand on Tide's capabilities, while keeping things easy to find.

    Screenshot_2020-04-24 tide - Rust

    Future Directions

    ๐Ÿš€ The next step for us is to continue to integrate http-types into Tide, focusing on the Request, Response, and Body types. This will likely coincide with a [email protected] release. After that our goal is to expand our capabilities around file serving and testing. And finally adding support for WebSockets, sessions, and TLS.

    We're excited for the future of Tide, and we're glad you're here with us!

    โž• Added

    • Enabled the use of ? in Endpoint #438
    • HttpService is now directly implemented on Server #442
    • โž• Added Route::serve_dir which can serve full directories #415
    • โž• Added a "getting started" section to the README #445
    • โž• Added Response::redirect_permanent #435
    • โž• Added Response::redirect_temporary #435
    • โž• Added the redirect submodule #450
    • โž• Added redirect::permanent #435
    • โž• Added the log submodule providing structured logging #451
    • โž• Added a test for chunked encoding #437
    • โž• Added a logo and favicon for rustdoc #459
    • โž• Added the sse submodule providing initial Server-Sent Events support #456
    • โž• Added tide::{Body, StatusCode}, re-exported from http-types #455
    • โž• Added instructions to the README how to run examples #460
    • โž• Added an example for a nesting tide server #429

    ๐Ÿ”„ Changed

    • All Endpoints now return Result<Into<Response>> #438
    • ๐Ÿ“‡ Renamed tide::redirect to tide::redirect::temporary #450
    • 0๏ธโƒฃ Logging middleware is now enabled by default #451
    • ๐Ÿ”’ Moved CORS middleware to the security submodule #453
    • ๐Ÿ‘ Allow tide::Result<Response> to be abbreviated as tide::Result #457
    • Replaced the use of IntoResponse with Into<Response> #463

    โœ‚ Removed

    • โœ‚ Removed unused server impl code #441
    • โœ‚ Removed the tide::server::Service struct #442
    • โœ‚ Removed the tide::server submodule #442
    • โœ‚ Removed the tide::middleware submodule #453
    • โœ‚ Removed the IntoResponse trait #463

    ๐Ÿ›  Fixed

    • ๐Ÿ›  Fixed CORS behavior if there is no origin header #439
    • ๐Ÿ›  Fixed documentation formatting in lib.rs #454
    • ๐Ÿ›  Fixed a stability issue in our tests regarding by opening random ports #446
  • v0.7.0 Changes

    April 17, 2020

    ๐Ÿ“„ This patch switches Tide to use http-types for its interface, and async-h1 as its default engine. Additionally we now allow middleware to be defined on a per-route basic. Put together this is effectively an overhaul of Tide's internals, and constitutes a fairly large change.

    ๐Ÿš€ If you're using Tide in production please be advised this release may have a different stability profile than what you've become used to in the past, and we advice upgrading with appropriate caution. If you find any critical bugs, filing a bug report on one of the issue trackers and reaching out directly over Discord is the quickest way to reach the team.

    ๐Ÿ’… The reason we're making these changes is that it will allow us to finally polish our error handling story, severely simplify internal logic, and enable many many other features we've been wanting to implement for years now. This is a big step for the project, and we're excited to be taking it together.

    โž• Added

    • Enables per-route middleware #399
    • โž• Added an example for chunked encoding #430

    ๐Ÿ”„ Changed

    • Made Endpoint::call generic over the lifetime #397
    • โœ‚ Removed Result from Request::cookie #413
    • 0๏ธโƒฃ Use async-h1 as the default engine #414
    • ๐Ÿ‘‰ Use http-types as the interface types #414

    ๐Ÿ›  Fixed

    • ๐Ÿ›  Fixed a path on the changelog.md #395
    • โœ‚ Removed unnecessary internal pin-project call #410