0.4.0
This release is a further polishing of Tide's APIs, and works towards
significantly improving Tide's user experience. The biggest question left
unanswered after this patch is how we want to do error handling, but aside from
that the end-user API should be pretty close to where we want it to be.
The biggest changes in this patch is endpoints now take Request
instead of
Context
. The new Request
and Response
types are no longer type aliases but
concrete types, making them substantially easier to use. This also means that
we've been able to fold in all the Ext
methods we were exposing, enabling
methods such as let values: Schema = req.body_json()?;
to deserialize an
incoming JSON body through a Serde
schema. This should make it significantly
easier to write APIs with Tide out of the box.
Example
Create a "hello world" app:
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/").get(|_| async move { "Hello, world!" });
app.listen("127.0.0.1:8080").await?;
Ok(())
}
Redirect from /nori
to /chashu
:
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
let mut app = tide::new();
app.at("/chashu").get(|_| async move { "meow" });
app.at("/nori").get(tide::redirect("/chashu"));
app.listen("127.0.0.1:8080").await?;
Ok(())
}
Added
- Added
logger::RequestLogger
based onlog
(replaceslogger:RootLogger
). - Added
Request
with inherent methods (replacesContext
). - Added
Server
(replacesApp
). - Added
Response
(replacing a type alias of the same name). - Added a
prelude
submodule, holding all public traits. - Added a
new
free function, a shorthand forServer::new
. - Added a
with_state
free function, a shorthand forServer::with_state
. - Added
Result
type alias (replacesEndpointResult
). - Added a
redirect
free function to redirect from one endpoint to another.
Changed
- Resolved an
#[allow(unused_mut)]
workaround. - Renamed
ExtractForms
toContextExt
. Response
is now a newly defined type.
Removed
- Removed
logger::RootLogger
(replaced bylogger:RequestLogger
). - Removed internal use of the
box_async
macro. - Removed
Context
(replaced byRequest
). - Removed the
Response
type alias (replaced by a newResponse
struct). - Removed
App
(replaced byServer
). - Temporarily disabled the multipart family of APIs, improving compilation
speed by ~30%. - Removed
EndpointResult
(replaced byResult
).