diff options
| author | Andrew <saintruler@gmail.com> | 2021-02-14 13:43:29 +0400 |
|---|---|---|
| committer | Andrew <saintruler@gmail.com> | 2021-02-14 13:43:29 +0400 |
| commit | 679f1c88ea9c56110f8f66f6f253fce30704e45e (patch) | |
| tree | c8eba9915a827c9dd667a1e8c553dda4f98365cc /spider/src/http_method.rs | |
| parent | 626e11a725934b64260e17e68d273727be76c57e (diff) | |
Changed structure of library
Diffstat (limited to 'spider/src/http_method.rs')
| -rw-r--r-- | spider/src/http_method.rs | 28 |
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; + } + } +} |