3 个版本
| 0.0.4 | 2019年12月9日 | 
|---|---|
| 0.0.2 | 2019年10月4日 | 
| 0.0.1 | 2019年10月4日 | 
65 在 #rocket-web 中
在 2 个crate中使用 (通过 rocket-config)
8KB
99 行
rocket-config
rocket-config 是为 Rust (nightly) 中的 Web 框架 Rocket 设计的 Fairing。
#![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();
}
依赖
~1.5MB
~38K SLoC