Remove unused Rocket::config method.

This commit is contained in:
Sergio Benitez 2016-10-16 03:21:34 -07:00
parent bc5ecb31df
commit 33f0274f62
1 changed files with 21 additions and 29 deletions

View File

@ -91,6 +91,27 @@ impl HyperHandler for Rocket {
}
impl Rocket {
/// Preprocess the request for Rocket-specific things. At this time, we're
/// only checking for _method in forms.
fn preprocess_request(&self, req: &mut Request, data: &Data) {
// Check if this is a form and if the form contains the special _method
// field which we use to reinterpret the request's method.
let data_len = data.peek().len();
let (min_len, max_len) = ("_method=get".len(), "_method=delete".len());
if req.content_type().is_form() && data_len >= min_len {
let form = unsafe {
from_utf8_unchecked(&data.peek()[..min(data_len, max_len)])
};
let mut form_items = FormItems(form);
if let Some(("_method", value)) = form_items.next() {
if let Ok(method) = value.parse() {
req.method = method;
}
}
}
}
#[doc(hidden)]
pub fn dispatch<'r>(&self, request: &'r Request, mut data: Data)
-> Result<Box<Responder + 'r>, StatusCode> {
@ -119,27 +140,6 @@ impl Rocket {
Err(StatusCode::NotFound)
}
/// Preprocess the request for Rocket-specific things. At this time, we're
/// only checking for _method in forms.
fn preprocess_request(&self, req: &mut Request, data: &Data) {
// Check if this is a form and if the form contains the special _method
// field which we use to reinterpret the request's method.
let data_len = data.peek().len();
let (min_len, max_len) = ("_method=get".len(), "_method=delete".len());
if req.content_type().is_form() && data_len >= min_len {
let form = unsafe {
from_utf8_unchecked(&data.peek()[..min(data_len, max_len)])
};
let mut form_items = FormItems(form);
if let Some(("_method", value)) = form_items.next() {
if let Ok(method) = value.parse() {
req.method = method;
}
}
}
}
// Call when no route was found. Returns true if there was a response.
#[doc(hidden)]
pub fn handle_error<'r>(&self,
@ -223,14 +223,6 @@ impl Rocket {
server.handle(self).unwrap();
}
/// Retrieves the configuration parameter named `name` for the current
/// environment. Returns Some(value) if the paremeter exists. Otherwise,
/// returns None.
pub fn config<S: AsRef<str>>(_name: S) -> Option<&'static str> {
// TODO: Implement me.
None
}
pub fn ignite() -> Rocket {
// Note: init() will exit the process under config errors.
let (config, initted) = config::init();