rocket-config-codegen

Crates.iorocket-config-codegen
lib.rsrocket-config-codegen
version0.0.4
sourcesrc
created_at2019-10-04 16:07:23.177943
updated_at2019-12-09 14:26:04.724374
descriptionProcedural macros for the rocket-config library.
homepage
repositoryhttps://github.com/CugeDe/rocket-config
max_upload_size
id169889
size7,391
CugeDe (CugeDe)

documentation

README

rocket-config

rocket-config is a Fairing designed for Rocket, a web framework for Rust (nightly).

#![feature(proc_macro_hygiene)]

#[macro_use] extern crate rocket;
extern crate rocket_config;
#[macro_use] extern crate rocket_config_codegen;

// This will generate the DieselConfiguration struct
// used below.
configuration!("diesel");

use rocket_config::Factory as ConfigurationsFairing;

// Here, `_configuration` contains the parsed configuration
// file "diesel.{json,yml,yaml}"
#[get("/<name>/<age>")]
fn hello(_configuration: DieselConfiguration, name: String, age: u8)
-> String
{
    format!("Hello, {} year old named {}!", age, name)
}

fn main() {
    rocket::ignite()
        .attach(ConfigurationsFairing::new())
        .mount("/hello", routes![hello]).launch();
}
Commit count: 9

cargo fmt