Cleanup core library documentation.

This commit is contained in:
Sergio Benitez 2016-09-29 21:44:27 -07:00
parent a6c176815c
commit 76cbc14d23
6 changed files with 29 additions and 6 deletions

View File

@ -1,6 +1,21 @@
#![feature(question_mark)]
#![feature(specialization)]
//! # Rocket
//!
//! Hello, and welcome to the core Rocket API documentation!
//!
//! This API documentation is highly technical and is purely a reference.
//! There's an [overview](https://rocket.rs/overview) of Rocket on the main site
//! as well as a [full, detailed guide](https://rocket.rs/guide). If you'd like
//! pointers on getting started, see the
//! [quickstart](https://rocket.rs/guide/quickstart) or [getting started
//! chapter](https://rocket.rs/guide/getting_started) of the guide.
//!
//! You may also be interested in looking at the [contrib API
//! documentation](../rocket_contrib), which contains JSON and templaring
//! support.
extern crate term_painter;
extern crate hyper;
extern crate url;
@ -12,6 +27,7 @@ pub mod logger;
pub mod form;
pub mod request;
pub mod response;
#[doc(hidden)]
pub mod content_type;
mod method;
@ -22,6 +38,7 @@ mod rocket;
mod codegen;
mod catcher;
#[doc(hidden)]
pub mod handler {
use super::{Request, Response, Error};
@ -29,6 +46,7 @@ pub mod handler {
pub type ErrorHandler = for<'r> fn(error: Error, &'r Request<'r>) -> Response<'r>;
}
#[doc(hidden)]
pub use logger::{RocketLogger, LoggingLevel};
pub use content_type::ContentType;
pub use codegen::{StaticRouteInfo, StaticCatchInfo};

View File

@ -84,6 +84,7 @@ impl Log for RocketLogger {
}
}
#[doc(hidden)]
pub fn init(level: LoggingLevel) {
let result = log::set_logger(|max_log_level| {
max_log_level.set(level.max_log_level().to_log_level_filter());

View File

@ -19,6 +19,7 @@ pub enum Method {
}
impl Method {
#[doc(hidden)]
pub fn from_hyp(method: &HyperMethod) -> Option<Method> {
match *method {
HyperMethod::Get => Some(Get),
@ -34,7 +35,7 @@ impl Method {
}
}
/// Whether the method supports a payload or not.
/// Whether an HTTP request with the given method supports a payload.
pub fn supports_payload(&self) -> bool {
match *self {
Put | Post | Delete | Patch => true,

View File

@ -4,10 +4,14 @@ mod from_request;
pub use self::request::Request;
pub use self::from_request::FromRequest;
#[doc(hidden)]
pub use hyper::server::Request as HyperRequest;
#[doc(hidden)]
pub use hyper::header::Headers as HyperHeaders;
#[doc(hidden)]
pub use hyper::header::Cookie as HyperCookie;
use hyper::header::CookieJar;
pub use hyper::header::CookiePair as Cookie;
use hyper::header::CookieJar;
pub type Cookies = CookieJar<'static>;

View File

@ -9,7 +9,6 @@ mod stream;
pub mod data;
pub use hyper::server::Response as HyperResponse;
pub use hyper::net::Fresh as HyperFresh;
pub use hyper::status::StatusCode;
pub use hyper::header;
@ -27,7 +26,7 @@ pub use self::data::Content;
use std::ops::{Deref, DerefMut};
pub type FreshHyperResponse<'a> = HyperResponse<'a, HyperFresh>;
pub type FreshHyperResponse<'a> = ::hyper::server::Response<'a, HyperFresh>;
pub struct Response<'a>(Box<Responder + 'a>);

View File

@ -8,11 +8,11 @@ pub enum Outcome<'h> {
/// Signifies a response that completed sucessfully.
Complete,
/// Signifies a response that failed internally.
Bad(HyperResponse<'h, HyperFresh>),
Bad(FreshHyperResponse<'h>),
/// Signifies a failing response where no further processing should happen.
FailStop,
/// Signifies a failing response whose request should be processed further.
FailForward(HyperResponse<'h, HyperFresh>),
FailForward(FreshHyperResponse<'h>),
}
impl<'h> Outcome<'h> {