Skip to content

Commit

Permalink
Update swagger ui to 5.13.0 (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn authored Apr 7, 2024
1 parent 330a42e commit 8be5be0
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/oapi/src/swagger_ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use salvo_core::{async_trait, Depot, Error, FlowCtrl, Handler, Request, Response
use serde::Serialize;

#[derive(RustEmbed)]
#[folder = "src/swagger_ui/v5.11.10"]
#[folder = "src/swagger_ui/v5.13.0"]
struct SwaggerUiDist;

const INDEX_TMPL: &str = r#"
Expand Down
3 changes: 0 additions & 3 deletions crates/oapi/src/swagger_ui/v5.11.10/swagger-ui-bundle.js

This file was deleted.

3 changes: 0 additions & 3 deletions crates/oapi/src/swagger_ui/v5.11.10/swagger-ui-es-bundle.js

This file was deleted.

2 changes: 0 additions & 2 deletions crates/oapi/src/swagger_ui/v5.11.10/swagger-ui.js

This file was deleted.

3 changes: 3 additions & 0 deletions crates/oapi/src/swagger_ui/v5.13.0/swagger-ui-bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions crates/oapi/src/swagger_ui/v5.13.0/swagger-ui-es-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions crates/oapi/src/swagger_ui/v5.13.0/swagger-ui.js

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion crates/proxy/src/hyper_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use salvo_core::rt::tokio::TokioIo;
use salvo_core::Error;
use tokio::io::copy_bidirectional;

use crate::{Client, HyperRequest, HyperResponse};
use crate::{Client, HyperRequest,Proxy, BoxedError, Upstreams,HyperResponse};

/// A [`Client`] implementation based on [`hyper_util::client::legacy::Client`].
#[derive(Clone, Debug)]
Expand All @@ -28,6 +28,18 @@ impl Default for HyperClient {
}
}
}

impl<U> Proxy<U, HyperClient>
where
U: Upstreams,
U::Error: Into<BoxedError>,
{
/// Create new `Proxy` which use default hyper util client.
pub fn use_hyper_client(upstreams: U) -> Self {
Proxy::new(upstreams, HyperClient::default())
}
}

impl HyperClient {
/// Create a new `HyperClient` with the given `HyperClient`.
pub fn new(inner: HyperUtilClient<HttpsConnector<HttpConnector>, ReqBody>) -> Self {
Expand Down
13 changes: 12 additions & 1 deletion crates/proxy/src/reqwest_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ use salvo_core::rt::tokio::TokioIo;
use salvo_core::Error;
use tokio::io::copy_bidirectional;

use crate::{Client, HyperRequest, HyperResponse};
use crate::{Client, HyperRequest, BoxedError, Proxy, Upstreams, HyperResponse};

/// A [`Client`] implementation based on [`reqwest::Client`].
#[derive(Default, Clone, Debug)]
pub struct ReqwestClient {
inner: InnerClient,
}

impl<U> Proxy<U, ReqwestClient>
where
U: Upstreams,
U::Error: Into<BoxedError>,
{
/// Create new `Proxy` which use default reqwest util client.
pub fn use_reqwest_client(upstreams: U) -> Self {
Proxy::new(upstreams, ReqwestClient::default())
}
}

impl ReqwestClient {
/// Create a new `ReqwestClient` with the given [`reqwest::Client`].
pub fn new(inner: InnerClient) -> Self {
Expand Down
5 changes: 2 additions & 3 deletions examples/proxy-simple/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use salvo::prelude::*;
use salvo::proxy::HyperClient;

#[tokio::main]
async fn main() {
Expand All @@ -10,13 +9,13 @@ async fn main() {
Router::new()
.host("127.0.0.1")
.path("<**rest>")
.goal(Proxy::new("https://www.rust-lang.org", HyperClient::default())),
.goal(Proxy::use_hyper_client("https://www.rust-lang.org")),
)
.push(
Router::new()
.host("localhost")
.path("<**rest>")
.goal(Proxy::new("https://crates.io", HyperClient::default())),
.goal(Proxy::use_hyper_client("https://crates.io")),
);

let acceptor = TcpListener::new("0.0.0.0:5800").bind().await;
Expand Down

0 comments on commit 8be5be0

Please sign in to comment.