Crates.io | nickel_cors |
lib.rs | nickel_cors |
version | 0.3.3 |
source | src |
created_at | 2018-04-23 16:43:16.298291 |
updated_at | 2019-05-16 11:36:55.605892 |
description | CORS Middleware for nickel.rs |
homepage | |
repository | https://github.com/duriantang/nickel_cors |
max_upload_size | |
id | 61989 |
size | 11,884 |
for more tech detail, see MDN CORS
Add this line to your Cargo.toml
nickel_cors = "0.3.3"
It's simple.
/* get server instance */
extern crate nickel;
use nickel::Nickel;
let mut server = Nickel::new();
/* enable cors */
extern crate nickel_cors;
server.utilize(nickel_cors::enable_cors);
This middleware will add these CORS headers to your every response:
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Max-Age: 86400
first you need install or switch to stable rust version.
rustup default stable
runing test use under line, or it will be failed.
cargo test