2016-03-28 09:34:09 +00:00
|
|
|
#![feature(specialization)]
|
2016-12-15 08:47:31 +00:00
|
|
|
#![feature(const_fn)]
|
2017-08-29 03:14:59 +00:00
|
|
|
#![feature(plugin, decl_macro)]
|
2017-06-24 09:49:16 +00:00
|
|
|
#![feature(try_trait)]
|
2018-03-22 09:02:37 +00:00
|
|
|
#![recursion_limit="256"]
|
2017-03-21 09:04:07 +00:00
|
|
|
|
|
|
|
#![plugin(pear_codegen)]
|
2016-03-19 02:05:29 +00:00
|
|
|
|
2017-06-11 08:03:59 +00:00
|
|
|
// TODO: Version URLs.
|
2017-11-22 18:58:20 +00:00
|
|
|
#![doc(html_root_url = "https://api.rocket.rs")]
|
2017-06-11 08:03:59 +00:00
|
|
|
|
2016-10-03 00:52:04 +00:00
|
|
|
//! # Rocket - Core API Documentation
|
2016-09-30 04:44:27 +00:00
|
|
|
//!
|
|
|
|
//! 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
|
2016-10-01 03:22:06 +00:00
|
|
|
//! [quickstart](https://rocket.rs/guide/quickstart) or [getting
|
2016-12-20 00:51:59 +00:00
|
|
|
//! started](https://rocket.rs/guide/getting-started) chapters of the guide.
|
2016-09-30 04:44:27 +00:00
|
|
|
//!
|
|
|
|
//! You may also be interested in looking at the [contrib API
|
2017-02-03 09:15:01 +00:00
|
|
|
//! documentation](/rocket_contrib), which contains JSON and templating
|
|
|
|
//! support, among other features.
|
2016-10-03 00:52:04 +00:00
|
|
|
//!
|
|
|
|
//! ## Libraries
|
|
|
|
//!
|
|
|
|
//! Rocket's functionality is split into three crates:
|
|
|
|
//!
|
|
|
|
//! 1. [Core](/rocket) - The core library. Needed by every Rocket application.
|
|
|
|
//! 2. [Codegen](/rocket_codegen) - Core code generation plugin. Should always
|
|
|
|
//! be used alongsize `rocket`, though it's not necessary.
|
|
|
|
//! 3. [Contrib](/rocket_contrib) - Provides useful functionality for many
|
2017-02-03 09:15:01 +00:00
|
|
|
//! Rocket applications. Completely optional.
|
2016-10-03 00:52:04 +00:00
|
|
|
//!
|
|
|
|
//! ## Usage
|
|
|
|
//!
|
|
|
|
//! The sanctioned way to use Rocket is via the code generation plugin. This
|
2017-02-03 09:15:01 +00:00
|
|
|
//! makes Rocket easier and safer to use and allows a somewhat stable API as
|
|
|
|
//! Rocket matures. To use Rocket with the code generation plugin in your
|
|
|
|
//! Cargo-based project, add the following to `Cargo.toml`:
|
2016-10-03 00:52:04 +00:00
|
|
|
//!
|
|
|
|
//! ```rust,ignore
|
|
|
|
//! [dependencies]
|
|
|
|
//! rocket = "*"
|
|
|
|
//! rocket_codegen = "*"
|
|
|
|
//! ```
|
|
|
|
//!
|
2016-12-20 00:51:59 +00:00
|
|
|
//! If you'll be deploying your project to [crates.io](https://crates.io),
|
|
|
|
//! you'll need to change the "*" to the current version of Rocket.
|
2016-10-03 00:52:04 +00:00
|
|
|
//!
|
2016-12-20 00:51:59 +00:00
|
|
|
//! Then, add the following to the top of your `main.rs` file:
|
2016-10-03 00:52:04 +00:00
|
|
|
//!
|
2016-10-18 02:29:58 +00:00
|
|
|
//! ```rust
|
2017-08-29 03:14:59 +00:00
|
|
|
//! #![feature(plugin, decl_macro)]
|
2017-02-02 10:16:21 +00:00
|
|
|
//! # #![allow(unused_attributes)]
|
2016-10-03 00:52:04 +00:00
|
|
|
//! #![plugin(rocket_codegen)]
|
|
|
|
//!
|
|
|
|
//! extern crate rocket;
|
|
|
|
//! ```
|
|
|
|
//!
|
2016-10-21 09:56:57 +00:00
|
|
|
//! See the [guide](https://rocket.rs/guide) for more information on how to
|
2016-10-18 02:29:58 +00:00
|
|
|
//! write Rocket applications. Here's a simple example to get you started:
|
|
|
|
//!
|
|
|
|
//! ```rust
|
2017-08-29 03:14:59 +00:00
|
|
|
//! #![feature(plugin, decl_macro)]
|
2016-10-18 02:29:58 +00:00
|
|
|
//! #![plugin(rocket_codegen)]
|
|
|
|
//!
|
|
|
|
//! extern crate rocket;
|
|
|
|
//!
|
|
|
|
//! #[get("/")]
|
|
|
|
//! fn hello() -> &'static str {
|
|
|
|
//! "Hello, world!"
|
|
|
|
//! }
|
|
|
|
//!
|
|
|
|
//! fn main() {
|
|
|
|
//! # if false { // We don't actually want to launch the server in an example.
|
2017-03-16 05:10:09 +00:00
|
|
|
//! rocket::ignite().mount("/", routes![hello]).launch();
|
2016-10-18 02:29:58 +00:00
|
|
|
//! # }
|
|
|
|
//! }
|
|
|
|
//! ```
|
2016-10-03 00:52:04 +00:00
|
|
|
//!
|
|
|
|
//! ## Configuration
|
|
|
|
//!
|
2017-02-03 09:15:01 +00:00
|
|
|
//! Rocket and Rocket libraries are configured via the `Rocket.toml` file and/or
|
|
|
|
//! `ROCKET_{PARAM}` environment variables. For more information on how to
|
|
|
|
//! configure Rocket, see the [configuration
|
|
|
|
//! section](https://rocket.rs/guide/overview/#configuration) of the guide as
|
|
|
|
//! well as the [config](/rocket/config) module documentation.
|
2016-10-18 02:29:58 +00:00
|
|
|
//!
|
|
|
|
//! ## Testing
|
|
|
|
//!
|
2017-06-11 10:39:30 +00:00
|
|
|
//! The [local](/rocket/local) module contains structures that facilitate unit
|
|
|
|
//! and itegration testing of a Rocket application. The [top-level `local`
|
|
|
|
//! module documentation](/rocket/local) and the [testing chapter of the
|
|
|
|
//! guide](https://rocket.rs/guide/testing/#testing) include detailed examples.
|
2016-10-04 00:09:13 +00:00
|
|
|
|
2018-04-12 23:07:37 +00:00
|
|
|
#[allow(unused_imports)] #[macro_use] extern crate rocket_codegen_next;
|
|
|
|
#[doc(hidden)] pub use rocket_codegen_next::*;
|
|
|
|
|
2016-10-04 00:09:13 +00:00
|
|
|
#[macro_use] extern crate log;
|
2017-03-21 09:04:07 +00:00
|
|
|
#[macro_use] extern crate pear;
|
2017-04-13 07:18:31 +00:00
|
|
|
#[cfg(feature = "tls")] extern crate rustls;
|
2017-07-12 11:13:46 +00:00
|
|
|
#[cfg(feature = "tls")] extern crate hyper_sync_rustls;
|
2017-09-14 00:22:22 +00:00
|
|
|
#[macro_use] extern crate percent_encoding;
|
2017-06-02 04:44:31 +00:00
|
|
|
extern crate yansi;
|
2016-03-12 18:45:19 +00:00
|
|
|
extern crate hyper;
|
2016-10-03 10:39:56 +00:00
|
|
|
extern crate toml;
|
2017-01-12 10:38:14 +00:00
|
|
|
extern crate num_cpus;
|
2017-01-21 03:31:46 +00:00
|
|
|
extern crate state;
|
2017-01-27 07:08:15 +00:00
|
|
|
extern crate cookie;
|
|
|
|
extern crate time;
|
2017-02-02 00:34:49 +00:00
|
|
|
extern crate memchr;
|
2017-03-07 09:19:06 +00:00
|
|
|
extern crate base64;
|
2017-03-21 09:04:07 +00:00
|
|
|
extern crate smallvec;
|
2018-02-26 04:32:10 +00:00
|
|
|
extern crate indexmap;
|
2017-06-20 01:29:26 +00:00
|
|
|
extern crate isatty;
|
2016-08-24 08:30:09 +00:00
|
|
|
|
2016-10-04 10:54:24 +00:00
|
|
|
#[cfg(test)] #[macro_use] extern crate lazy_static;
|
|
|
|
|
2016-09-30 22:20:11 +00:00
|
|
|
#[doc(hidden)] #[macro_use] pub mod logger;
|
2018-03-22 09:02:37 +00:00
|
|
|
#[macro_use] mod docify;
|
2017-06-06 20:41:04 +00:00
|
|
|
pub mod local;
|
2016-10-08 11:29:20 +00:00
|
|
|
pub mod http;
|
2016-08-24 08:30:09 +00:00
|
|
|
pub mod request;
|
|
|
|
pub mod response;
|
2016-10-08 02:27:26 +00:00
|
|
|
pub mod outcome;
|
2016-10-15 01:57:36 +00:00
|
|
|
pub mod config;
|
2016-10-25 11:24:07 +00:00
|
|
|
pub mod data;
|
2016-12-15 08:47:31 +00:00
|
|
|
pub mod handler;
|
2017-04-20 20:43:01 +00:00
|
|
|
pub mod fairing;
|
2017-06-12 22:08:34 +00:00
|
|
|
pub mod error;
|
2016-03-12 18:45:19 +00:00
|
|
|
|
2016-04-01 23:54:53 +00:00
|
|
|
mod router;
|
|
|
|
mod rocket;
|
2016-04-03 10:36:30 +00:00
|
|
|
mod codegen;
|
2016-04-06 10:26:43 +00:00
|
|
|
mod catcher;
|
2016-12-15 08:47:31 +00:00
|
|
|
mod ext;
|
2016-04-02 07:51:40 +00:00
|
|
|
|
2016-10-08 11:42:22 +00:00
|
|
|
#[doc(inline)] pub use response::Response;
|
2016-09-30 22:20:11 +00:00
|
|
|
#[doc(inline)] pub use handler::{Handler, ErrorHandler};
|
2016-10-08 11:42:22 +00:00
|
|
|
#[doc(hidden)] pub use codegen::{StaticRouteInfo, StaticCatchInfo};
|
2016-10-25 11:39:31 +00:00
|
|
|
#[doc(inline)] pub use outcome::Outcome;
|
2016-10-25 11:27:16 +00:00
|
|
|
#[doc(inline)] pub use data::Data;
|
2017-06-06 20:41:04 +00:00
|
|
|
#[doc(inline)] pub use config::Config;
|
2017-06-12 22:08:34 +00:00
|
|
|
#[doc(inline)] pub use error::Error;
|
2016-10-04 00:09:13 +00:00
|
|
|
pub use router::Route;
|
2017-01-21 03:31:46 +00:00
|
|
|
pub use request::{Request, State};
|
2016-04-06 10:26:43 +00:00
|
|
|
pub use catcher::Catcher;
|
2016-04-01 23:54:53 +00:00
|
|
|
pub use rocket::Rocket;
|
2016-10-03 10:39:56 +00:00
|
|
|
|
2016-11-04 13:35:04 +00:00
|
|
|
/// Alias to [Rocket::ignite()](/rocket/struct.Rocket.html#method.ignite).
|
|
|
|
/// Creates a new instance of `Rocket`.
|
2016-10-03 10:39:56 +00:00
|
|
|
pub fn ignite() -> Rocket {
|
|
|
|
Rocket::ignite()
|
|
|
|
}
|
2016-11-04 13:35:04 +00:00
|
|
|
|
|
|
|
/// Alias to [Rocket::custom()](/rocket/struct.Rocket.html#method.custom).
|
|
|
|
/// Creates a new instance of `Rocket` with a custom configuration.
|
2017-01-12 02:31:37 +00:00
|
|
|
pub fn custom(config: config::Config, log: bool) -> Rocket {
|
|
|
|
Rocket::custom(config, log)
|
2016-11-04 13:35:04 +00:00
|
|
|
}
|