Skip to content

fxbox/iron-cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

iron-cors

Helper to add CORS to a Iron server

Example

extern crate iron;
extern crate router;
extern crate iron_cors;

fn main() {
    use iron_cors::CORS;
    use iron::prelude::*;
    use iron::method::Method;
    use iron::status::Status;
    use router::Router;

    let mut router = Router::new();

    router.get("/test", handler);
    router.post("/test", handler);
    fn handler(_: &mut Request) -> IronResult<Response> {
       Ok(Response::with(Status::Ok))
    }

    let cors = CORS::new(vec![
         (vec![Method::Get, Method::Post], "test".to_owned())
    ]);

    let mut chain = Chain::new(router);
    chain.link_after(cors);
    
    Iron::new(chain).http("localhost:3000").unwrap();
}

About

Helper to add CORS to a Iron server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages