Skip to content

Commit

Permalink
feat(kv-web): complete MVP
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Nov 7, 2024
1 parent 453dbd6 commit 20bc65d
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 245 deletions.
14 changes: 8 additions & 6 deletions examples/web/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ impl<C: Send + Sync> store::Handler<C> for Handler {
Ok(nats) => nats,
Err(err) => return Ok(Err(store::Error::Other(format!("{err:#}")))),
};
let Some(prefix) = url.path().strip_prefix('/') else {
return Ok(Err(store::Error::Other("invalid URL".to_string())));
};
let prefix = url.path();
let prefix = prefix.strip_prefix('/').unwrap_or(prefix);
let wrpc = match wrpc_transport_nats::Client::new(nats, prefix, None)
.await
.context("failed to construct wRPC client")
Expand Down Expand Up @@ -221,11 +220,14 @@ impl<C: Send + Sync> store::Handler<C> for Handler {
.try_into()
.context("failed to convert rustls client config to QUIC client config")?;
ep.set_default_client_config(quinn::ClientConfig::new(Arc::new(conf)));
let conn = match ep.connect(addr, san).context("failed to connect") {
let conn = match ep
.connect(addr, san)
.context("failed to connect using QUIC")
{
Ok(ep) => ep,
Err(err) => return Ok(Err(store::Error::Other(format!("{err:#}")))),
};
let conn = match conn.await.context("failed to establish connection") {
let conn = match conn.await.context("failed to establish QUIC connection") {
Ok(ep) => ep,
Err(err) => return Ok(Err(store::Error::Other(format!("{err:#}")))),
};
Expand Down Expand Up @@ -276,7 +278,7 @@ impl<C: Send + Sync> store::Handler<C> for Handler {
let conn = match ep
.connect(format!("https://{}", url.authority()))
.await
.context("failed to establish connection")
.context("failed to establish WebTransport connection")
{
Ok(ep) => ep,
Err(err) => return Ok(Err(store::Error::Other(format!("{err:#}")))),
Expand Down
Loading

0 comments on commit 20bc65d

Please sign in to comment.