github cloudwego/volo volo-http-0.3.0
Volo-HTTP 0.3.0

10 hours ago

What's Changed

Notable Changes

Since Volo-HTTP 0.2.14

  • Server side
    • Support MultiPart #511
  • Client Side
    • Use less Result in client #509
    • Support CookieJar #512
    • Refactor ClientBuilder, Target and CallOpt #528
  • Generic
    • Wrap hyper::body::Incoming by Body #504

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 Bodys (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 and ClientBuilder::callee_name are renamed to ClientBuilder::user_agent and ClientBuilder::default_host
  • ClientBuilder::fail_on_status has been removed, you should use FailOnStatus layer instead
  • RequestBuilder::set_request_timeout has been removed, users should use RequestBuilder::with_callopt and CallOpt::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 implement volo::client::Apply for your service discover

Detailed Pull Requests

Full Changelog: volo-http-0.2.14...volo-http-0.3.0

Don't miss a new volo release

NewReleases is sending notifications on new releases.