Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

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

INACTIVE - Helper to add CORS to a Iron server

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages