#gotham #cors #middleware #basic #router #server #pipeline

gotham-cors-middleware

A small crate to add basic CORS functionality to Gotham apps

2 unstable releases

Uses old Rust 2015

0.2.1 Oct 23, 2018
0.2.0 Oct 23, 2018
0.1.0 Jun 26, 2018

#10 in #gotham

MIT/Apache

12KB
195 lines

Gotham CORS Middleware

This library is aimed to provide CORS functionality to Gotham.rs servers.

Currently this is a very simple implementation with limited customisability.

Requires rust 1.26 or later.

Usage:

extern crate gotham;
extern crate gotham_cors_middleware;

use gotham::pipeline::new_pipeline;
use gotham_cors_middleware::CORSMiddleware;
use gotham::pipeline::single::single_pipeline;
use gotham::router::builder::*;
use gotham::router::Router;

pub fn router() -> Router {
    let (chain, pipeline) = single_pipeline(
        new_pipeline()
            .add(CORSMiddleware::default())
            .build(),
    );

    build_router(chain, pipeline, |route| {
     // Routes
    }
}

Roadmap:

  • Add integration tests
  • Add builder that would allow header customisation
  • Add documentation
  • See how next version of Gotham requires changes to middeware structure

lib.rs:

Library aimed at providing CORS functionality for Gotham based servers.

Currently a very basic implementation with limited customisability.

Dependencies

~17MB
~334K SLoC