tangled
alpha
login
or
join now
bad-example.com
/
jacquard
forked from
nonbinary.computer/jacquard
A better Rust ATProto crate
0
fork
atom
overview
issues
pulls
pipelines
Compare changes
Choose any two refs to compare.
base:
main
fix/url-leading-double-slash
no tags found
compare:
main
fix/url-leading-double-slash
no tags found
go
+9
-6
1 changed file
expand all
collapse all
unified
split
crates
jacquard
src
client.rs
+9
-6
crates/jacquard/src/client.rs
···
10
use std::future::Future;
11
12
use bytes::Bytes;
13
-
pub use error::{ClientError, Result};
14
use http::{
15
HeaderName, HeaderValue, Request,
16
header::{AUTHORIZATION, CONTENT_TYPE, InvalidHeaderValue},
···
152
R: XrpcRequest,
153
C: XrpcClient + ?Sized,
154
{
155
-
// Build URI: base_uri + /xrpc/ + NSID
156
-
let mut uri = format!("{}/xrpc/{}", client.base_uri(), R::NSID);
0
0
0
0
157
158
// Add query parameters for Query methods
159
if let XrpcMethod::Query = R::METHOD {
160
let qs = serde_html_form::to_string(&request).map_err(error::EncodeError::from)?;
161
if !qs.is_empty() {
162
-
uri.push('?');
163
-
uri.push_str(&qs);
164
}
165
}
166
···
170
XrpcMethod::Procedure(_) => http::Method::POST,
171
};
172
173
-
let mut builder = Request::builder().method(method).uri(&uri);
174
175
// Add Content-Type for procedures
176
if let XrpcMethod::Procedure(encoding) = R::METHOD {
···
10
use std::future::Future;
11
12
use bytes::Bytes;
13
+
pub use error::{ClientError, Result, TransportError};
14
use http::{
15
HeaderName, HeaderValue, Request,
16
header::{AUTHORIZATION, CONTENT_TYPE, InvalidHeaderValue},
···
152
R: XrpcRequest,
153
C: XrpcClient + ?Sized,
154
{
155
+
// Configure the XRPC endpoint
156
+
let mut url: reqwest::Url = client
157
+
.base_uri()
158
+
.parse()
159
+
.map_err(|e| error::EncodeError::Other(format!("failed to parse base_uri: {e}").into()))?;
160
+
url.set_path(&format!("/xrpc/{}", R::NSID));
161
162
// Add query parameters for Query methods
163
if let XrpcMethod::Query = R::METHOD {
164
let qs = serde_html_form::to_string(&request).map_err(error::EncodeError::from)?;
165
if !qs.is_empty() {
166
+
url.set_query(Some(&qs))
0
167
}
168
}
169
···
173
XrpcMethod::Procedure(_) => http::Method::POST,
174
};
175
176
+
let mut builder = Request::builder().method(method).uri(&url.to_string());
177
178
// Add Content-Type for procedures
179
if let XrpcMethod::Procedure(encoding) = R::METHOD {