Implemented endpoint to write settings

This commit is contained in:
Antoine Gersant 2018-10-27 17:26:19 -07:00
parent 0ebcc8a280
commit 769c12833a

View file

@ -12,7 +12,7 @@ const CURRENT_MAJOR_VERSION: i32 = 2;
const CURRENT_MINOR_VERSION: i32 = 2;
pub fn get_routes() -> Vec<rocket::Route> {
routes![version, initial_setup, get_settings,]
routes![version, initial_setup, get_settings, put_settings]
}
struct Auth {
@ -88,3 +88,9 @@ fn get_settings(db: State<DB>, _admin_rights: AdminRights) -> Result<Json<Config
let config = config::read::<DB>(&db)?;
Ok(Json(config))
}
#[put("/settings", data = "<config>")]
fn put_settings(db: State<DB>, _admin_rights: AdminRights, config: Json<Config>) -> Result<(), errors::Error> {
config::amend::<DB>(&db, &config)?;
Ok(())
}