Crate pencil [] [src]

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 pencil;

use pencil::Pencil;
use pencil::{Request, PencilResult, Response};
use 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");
}

Reexports

pub use types::{PenHTTPError, PenUserError};
pub use wrappers::{Request, Response};
pub use http_errors::{HTTPError};
pub use json::jsonify;
pub use config::{Config};
pub use helpers::{PathBound, safe_join, abort, redirect, escape, send_file, 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

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.

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.