selaux / iron-pack Goto Github PK
View Code? Open in Web Editor NEWZero-configuration compression middleware for iron
Zero-configuration compression middleware for iron
My code:
extern crate env_logger;
extern crate iron;
extern crate iron_pack;
extern crate logger;
extern crate mount;
extern crate staticfile;
#[macro_use]
extern crate log;
use std::env;
use iron::prelude::*;
use logger::Logger;
use iron_pack::CompressionMiddleware;
fn main() {
env_logger::init();
info!("Initializing MobTag server...");
let (logger_before, logger_after) = Logger::new(None);
let mut chain = Chain::new(no_op_handler);
chain.link_before(logger_before);
// Static file serving
let env_static_path: String;
match env::var("MOBTAG_STATIC_PATH") {
Ok(val) => {
env_static_path = val;
info!("Static files will be server from {:?}", env_static_path);
}
Err(e) => {
error!(
"Could not retrive the static file directory. The error returned was: {}",
e
);
panic!();
}
}
chain.link_after(CompressionMiddleware);
chain.link_after(logger_after);
info!("MobTag server listening on port 5000");
Iron::new(chain).http("localhost:5000").unwrap();
}
fn no_op_handler(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((iron::status::Ok, "Hello World")))
}
I am pretty new to Rust and might be missing something obvious...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.