Function nya::create_middleware[][src]

pub fn create_middleware<T>(x: T) -> Box<T>

A convenience function that creates middleware.

Takes a closure and boxes it so it can be (more or less) safely added to the middleware chain and so that we don't have to worry about lifetimes. This closure itself takes a files argument that is a Vec of SimpleFiles. This Vec can be modified in place and doesn't have to be returned.

Example

let func = nya::create_middleware(|files: &mut Vec<nya::SimpleFile>| {
    let file = &mut files[0];
    file.content = "haha hello".to_string();
});

nya::run(vec![func], Some("fixtures/example"), None).unwrap();