summaryrefslogtreecommitdiff
path: root/spider/src/http_method.rs
diff options
context:
space:
mode:
Diffstat (limited to 'spider/src/http_method.rs')
-rw-r--r--spider/src/http_method.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/spider/src/http_method.rs b/spider/src/http_method.rs
new file mode 100644
index 0000000..b1cc884
--- /dev/null
+++ b/spider/src/http_method.rs
@@ -0,0 +1,28 @@
+use std::fmt;
+
+pub enum HttpMethod {
+ GET, POST
+}
+
+impl fmt::Display for HttpMethod {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match *self {
+ HttpMethod::GET => write!(f, "GET"),
+ HttpMethod::POST => write!(f, "POST")
+ }
+ }
+}
+
+impl HttpMethod {
+ pub fn parse(s: String) -> Option<HttpMethod> {
+ if s == "GET" {
+ return Some(HttpMethod::GET);
+ }
+ else if s == "POST" {
+ return Some(HttpMethod::POST);
+ }
+ else {
+ return None;
+ }
+ }
+}