Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ hyper = "0.9.6"
semver = "0.2.2"
slug = "0.1.1"
env_logger = "0.3"
iron = "0.3.0"
staticfile = { version = "0.2.0", features = [ "cache" ] }

[dependencies.cargo]
git = "https://github.com/rust-lang/cargo.git"
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ extern crate hyper;
extern crate time;
extern crate semver;
extern crate slug;
extern crate iron;
extern crate staticfile;

pub use self::build_doc::{build_doc, get_package, source_path, update_sources};
pub use self::copy::{copy_dir, copy_doc_dir};
Expand All @@ -19,6 +21,7 @@ pub use self::docbuilder::options::DocBuilderOptions;

pub mod db;
pub mod utils;
pub mod web;
mod build_doc;
mod copy;
mod docbuilder;
Expand Down
23 changes: 23 additions & 0 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Web interface of cratesfyi

pub use self::rustdoc::start_rustdoc_web_server;

mod rustdoc;

use ::db;
use iron::prelude::*;
use iron::{BeforeMiddleware, typemap};
use postgres;


/// Simple iron middleware for database connection
struct DbConnection;

impl typemap::Key for DbConnection { type Value = postgres::Connection; }

impl BeforeMiddleware for DbConnection {
fn before(&self, req: &mut Request) -> IronResult<()> {
req.extensions.insert::<DbConnection>(db::connect_db().unwrap());
Ok(())
}
}
Loading