[−][src]Crate sharp_pencil
Pencil is a microframework for Rust inspired by Flask.
Installation
This crate is called pencil
and you can depend on it via cargo:
[dependencies]
pencil = "*"
Quickstart
A short introduction to Pencil.
A Minimal Application
A minimal Pencil application looks something like this:
extern crate sharp_pencil; use sharp_pencil::Pencil; use sharp_pencil::{Request, PencilResult, Response}; use sharp_pencil::method::Get; fn hello(_: &mut Request) -> PencilResult { Ok(Response::from("Hello World!")) } fn main() { let mut app = Pencil::new("/web/hello"); app.route("/", &[Get], "hello", hello); app.run("127.0.0.1:5000"); }
Re-exports
pub use types::PenHTTPError; |
pub use types::PenUserError; |
pub use wrappers::Request; |
pub use wrappers::Response; |
pub use http_errors::HTTPError; |
pub use json::jsonify; |
pub use config::Config; |
pub use helpers::PathBound; |
pub use helpers::safe_join; |
pub use helpers::abort; |
pub use helpers::redirect; |
pub use helpers::escape; |
pub use helpers::send_file; |
pub use helpers::send_from_directory; |
Modules
config | This module implements configuration related stuff. |
datastructures | This module implements some useful objects. |
helpers | This module implements various helpers. |
http_errors | This module implements a number of http errors. |
json | This module implements helpers for the JSON support in Pencil. |
method | This module exports the http method. |
routing | This module implements the dispatcher. |
wrappers | This module implements simple request and response objects. |
Structs
ContentLength |
|
ContentType |
|
Cookie |
|
Handlebars | The single entry point of your Handlebars templates |
Headers | A map of header fields on requests and responses. |
Module | Represents a module. |
Pencil | The pencil type. It acts as the central application object. Once it is created it will act as a central registry for the view functions, the URL rules and much more. |
SetCookie |
|
UserError | The Pencil User Error type. |
Enums
PencilError | The Pencil Error type. |
Type Definitions
AfterRequestFunc | After request func type. |
BeforeRequestFunc | Before request func type. |
HTTPErrorHandler | HTTP Error handler type. |
PencilResult | The Pencil Result type. |
TeardownRequestFunc | Teardown request func type. |
UserErrorHandler | User Error handler type. |
ViewArgs | View arguments type. |
ViewFunc | View function type. |