Stream a Body With Trailers in hyper 1.0 and axum 0.7
Hyper supports sending HTTP/1.1 Chunked Trailer Fields as of v1.1.0. The http-body is now at v1.0 as well and uses frames to allow a stream to return data and trailers.
Hyper supports sending HTTP/1.1 Chunked Trailer Fields as of v1.1.0. The http-body is now at v1.0 as well and uses frames to allow a stream to return data and trailers.
Hyper is designed to support streaming bodies. The current version of axum, v0.6, supports streaming a response. If we want to include trailers (sometimes called "trailing headers") then we need to implement our own custom body.
A company often has a landing page for first time visitors that is optimized for describing and educating that person on what product or service the company is offering. This page is usually not useful for people already familiar with the company. Ideally, a new user would see the marketing landing page and the returning user would see a more functional page. There are two common approaches to solving this problem that both have pitfalls. I want to explore a third option using Fastly's Compute@Edge offering.
When writing tests, we do not want to hit the external API each time we run our tests. If we are coming from a dynamic language, such as Node.JS, we may want to a solution like fetch-mock which will patch the implementation of fetch
at runtime. This is not practical in Rust. There are some attempts, like the hotpatch crate, but we will use a different strategy.
Lucet is Fastly's native WebAssembly compiler and runtime. Using the Lucet runtime and Rust's wasm32-unknown-wasi
target, we can create a WASM program that runs on the server.
Lucet is Fastly's native WebAssembly compiler and runtime. I am a big fan of Rust, Fastly and WASM. Especially WASM on the server via WASI. I jumped right in and tried to get my own lucet program running, but the setup is a rather long process. My plan was to introduce lucet to some colleagues at my local Rust meetup. I am a huge fan of Rust, but the compile times are an issue. Spending 30 minutes on setup was a non-starter. I was excited when I saw that Fastly published a Docker container: