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
//! [WIP] Service controller use std::collections::HashMap; use protocol::http::HttpStatus; /// Expose more message details to service provider, and help to process /// http requests. #[derive(Clone, Default, Debug, PartialEq)] pub struct Controller { /// Request target in http message pub http_url: Option<String>, /// Http headers pub headers: HashMap<String, String>, /// Http status code pub status: Option<HttpStatus>, /// Request body in raw bytes pub request_body: Vec<u8>, /// Response body in raw bytes pub response_body: Vec<u8>, } impl Controller { /// Set Content-Type field in http headers. pub fn set_content_type(&mut self, s: &str) { self.headers .insert("Content-Type".to_string(), s.to_string()); } }