Skip to content

sbditto85/iron_vhosts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iron Vhosts

Vhost handler for the Iron web framework.

Example

extern crate iron;
extern crate iron_vhosts;

use iron::prelude::*;
use iron::status;
use iron_vhosts::Vhosts;

fn main () {
    //Default handler passed to new
    let mut vhosts = Vhosts::new(|_: &mut Request| Ok(Response::with((status::Ok, "vhost"))));
    
    //Add any host specific handlers
    vhosts.add_host("localhost", localhost_handler);
    vhosts.add_host("media.localhost", media_handler);
    
    fn localhost_handler(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "localhost")))
    }

    fn media_handler(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "media")))
    }

    Iron::new(vhosts).http("localhost:3000").unwrap();
}

Installation

If you're using cargo, just add iron_vhosts to your Cargo.toml.

[dependencies]

iron_vhosts = "*"

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages