summaryrefslogtreecommitdiff
path: root/spider/src/http_method.rs
blob: e3089835422ee9113d34bf40ceb30a28e6737d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::fmt;

// TODO(andrew): add rest of the methods.
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;
        }
    }
}