aboutsummaryrefslogtreecommitdiff
path: root/src/barbfile.rs
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2022-02-10 23:49:58 +0000
committerGuillaume Pasquet <dev@etenil.net>2022-02-10 23:49:58 +0000
commit9101f32f7d258984fb8f8247de8bc661acd69d47 (patch)
tree4a8b755c1ae4f96f14f5f5f8f2cd5e23b65c2c58 /src/barbfile.rs
parent9f4fec0dce1e931356c567fa11d9435f44fbbf50 (diff)
Working requests
Diffstat (limited to 'src/barbfile.rs')
-rw-r--r--src/barbfile.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/barbfile.rs b/src/barbfile.rs
index 26ab583..4d304e2 100644
--- a/src/barbfile.rs
+++ b/src/barbfile.rs
@@ -1,4 +1,3 @@
-use std::matches;
use std::str::FromStr;
use std::string::ToString;
use std::{error::Error, fmt};
@@ -14,7 +13,7 @@ impl fmt::Display for BarbParseError {
}
}
-enum Method {
+pub enum Method {
GET,
PUT,
POST,
@@ -49,6 +48,16 @@ impl ToString for Method {
}
}
+impl Method {
+ pub fn takes_body(&self) -> bool {
+ match self {
+ Method::GET => false,
+ Method::DELETE => false,
+ _ => true
+ }
+ }
+}
+
#[derive(Debug)]
struct Header {
name: String,
@@ -100,6 +109,10 @@ impl BarbFile {
pub fn url(&self) -> &String {
&self.header.url
}
+
+ pub fn body(&self) -> &Option<String> {
+ &self.body
+ }
}
fn decode_url_line(line: &str) -> Result<(Method, String), BarbParseError> {