What's Changed
Notable Changes
Since Volo-HTTP 0.2.14
Bugfix
- Fixed the issue where the
Form
was rejected due to incorrect judgment #538 - Fixed an issue where DNS resolution would always prefer IPv4 addresses #538
Break Changes
Adjust positions of some mods #499
Because the positions of the modules were confusing before, we adjusted the positions of some modules for a better user experience.
volo_http::json::Json
->volo_http::server::extract::Json
volo_http::extension::Extension
->volo_http::utils::Extension
volo_http::cookie::CookieJar
->volo_http::utils::cookie::CookieJar
In addition, Json
and Extension
were not be re-exported in volo_http
, user should import them by its full path.
All Body
s (http_body::Body
) are unified into volo_http::body::Body
#504
For a more unified experience, we wrap hyper::body::Incoming
by volo_http::body::Body
, and default generic types of Router
, MethodRouter
, Route
and FromRequest
have been updated from Incoming
to Body
.
If you are using Router
(and MethodRouter
, Route
) and specify Incoming
as its generic type, update it to Body
or remove the generic type directly.
If you implemented FromRequest
without use generic type (use default generic type), the argument type should be updated.
// old
let _: Router<Incoming> = Router::new().route(...);
// new
let _: Router<Body> = Router::new().route(...);
// or remove generic type
let _: Router = Router::new().route(...);
// old
impl FromRequest for Foo {
type Rejection = ...;
async fn from_request(
cx: &mut ServerContext,
parts: Parts,
body: Incoming,
) -> Result<Self, Self::Rejection> {
}
}
// new
impl FromRequest for Foo {
type Rejection = ...;
async fn from_request(
cx: &mut ServerContext,
parts: Parts,
body: Body,
) -> Result<Self, Self::Rejection> {
}
}
// or use generic type B
impl<B> FromRequest<B> for Foo
where
B: Body + Send,
B::Data: Send,
B::Error: Send,
{
type Rejection = ...;
async fn from_request(
cx: &mut ServerContext,
parts: Parts,
body: B,
) -> Result<Self, Self::Rejection> {
}
}
Most client methods no longer return Result
#509
For a better user experience, we changed the return value of some methods of client that originally returned Result<Self>
to Self
.
In other words, chain calls can be used fluently without adding unwrap
, expect
or ?
in between, they can be removed.
// old
let _ = client.get("http://example.com/").unwrap().send().await;
// new
let _ = client.get("http://example.com/").send().await;
Refactor ClientBuilder
, Target
and CallOpt
#522 #528
In order to make the service function more independent, and unify the user experience of Volo-Thrift, Volo-gRPC and Volo-HTTP, while retaining the characteristics of Volo-HTTP, we refactored ClientBuilder
, Target
and CallOpt
.
ClientBuilder::caller_name
andClientBuilder::callee_name
are renamed toClientBuilder::user_agent
andClientBuilder::default_host
ClientBuilder::fail_on_status
has been removed, you should useFailOnStatus
layer insteadRequestBuilder::set_request_timeout
has been removed, users should useRequestBuilder::with_callopt
andCallOpt::new().with_timeout(...)
instead
// old
let mut builder= ClientBuilder::new();
builder.caller_name(...).callee_name(...).fail_on_status(...);
let client = builder.build();
client.get(...).set_request_timeout(...).send().await;
// new
let mut builder= ClientBuilder::new();
builder.user_agent(...).default_host(...).layer_outer(FailOnStatus::xxx());
let client = builder.build();
client.get(...).with_callopt(CallOpt::new().with_timeout(...)).send().await;
And if you are using customized service discover, you should also pay attention to the following changes:
TargetParser
has been removed, you should implementvolo::client::Apply
for your service discover
Detailed Pull Requests
- chore(volo-http): add docs for test helpers by @yukiiiteru in #497
- chore(volo-http): adjust positions of some mods by @yukiiiteru in #499
- chore(volo-http): refactor
RequestPartsExt
by @yukiiiteru in #501 - chore(volo-http): refactor websocket by @yukiiiteru in #503
- chore(volo-http): wrap
hyper::body::Incoming
byBody
by @yukiiiteru in #504 - chore(volo-http): add mock transport service for client by @yukiiiteru in #506
- feat(http): avoid unnecessary router params vec expansion by @StellarisW in #508
- chore(volo-http): use less
Result
in client by @yukiiiteru in #509 - feat(http): add multipart for server by @StellarisW in #511
- feat(http): add cookie feature for client by @StellarisW in #512
- chore(volo-http): implement
source
forError
s by @yukiiiteru in #519 - chore(volo-http): add TimeoutLayer and FailOnStatus layer by @yukiiiteru in #522
- chore(volo-http): refactor
ClientBuilder
,Target
andCallOpt
by @yukiiiteru in #528 - chore(volo-http): add feature
json-utf8-lossy
by @yukiiiteru in #530 - chore(volo-http): fix previously missed changes to
Body
by @yukiiiteru in #531 - fix(volo-http): fix wrong rule of setting header
Host
by @yukiiiteru in #532 - chore(volo-http): combine C/S Request and C/S Response types by @yukiiiteru in #534
- feat(volo-http): add client ip by @StellarisW in #535
- chore(volo-http): introduce
hyper_util::server::auto
by @yukiiiteru in #537 - fix(volo-http): add mime parsing in server, do not always prefer ipv4 in client dns by @yukiiiteru in #538
Full Changelog: volo-http-0.2.14...volo-http-0.3.0