Skip to content

Commit 5e25cab

Browse files
jgraettingersoedirgo
authored andcommitted
builder: select() shoudn't override METHOD
Also add build() for obtaining but not executing the request. This allows for further tweaking and/or logging of the pre-flight request.
1 parent 10c2596 commit 5e25cab

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/builder.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ impl Builder {
154154
where
155155
T: Into<String>,
156156
{
157-
self.method = Method::GET;
158157
self.queries.push(("select".to_string(), columns.into()));
159158
self
160159
}
@@ -548,8 +547,8 @@ impl Builder {
548547
self
549548
}
550549

551-
/// Executes the PostgREST request.
552-
pub async fn execute(mut self) -> Result<Response, Error> {
550+
/// Build the PostgREST request.
551+
pub fn build(mut self) -> reqwest::RequestBuilder {
553552
if let Some(schema) = self.schema {
554553
let key = match self.method {
555554
Method::GET | Method::HEAD => "Accept-Profile",
@@ -570,8 +569,11 @@ impl Builder {
570569
.headers(self.headers)
571570
.query(&self.queries)
572571
.body(self.body.unwrap_or_default())
573-
.send()
574-
.await
572+
}
573+
574+
/// Executes the PostgREST request.
575+
pub async fn execute(self) -> Result<Response, Error> {
576+
self.build().send().await
575577
}
576578
}
577579

0 commit comments

Comments
 (0)