mirror of
https://github.com/agersant/polaris
synced 2024-12-02 17:49:10 +00:00
Added preferences endpoint
This commit is contained in:
parent
ea299312d0
commit
2ee33e7615
1 changed files with 19 additions and 1 deletions
|
@ -7,7 +7,7 @@ use std::path::PathBuf;
|
|||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
use config::{self, Config};
|
||||
use config::{self, Config, Preferences};
|
||||
use db::DB;
|
||||
use errors;
|
||||
use index;
|
||||
|
@ -27,6 +27,8 @@ pub fn get_routes() -> Vec<rocket::Route> {
|
|||
initial_setup,
|
||||
get_settings,
|
||||
put_settings,
|
||||
get_preferences,
|
||||
put_preferences,
|
||||
trigger_index,
|
||||
auth,
|
||||
browse_root,
|
||||
|
@ -148,6 +150,22 @@ fn put_settings(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[get("/preferences")]
|
||||
fn get_preferences(db: State<DB>, auth: Auth) -> Result<Json<Preferences>, errors::Error> {
|
||||
let preferences = config::read_preferences::<DB>(&db, &auth.username)?;
|
||||
Ok(Json(preferences))
|
||||
}
|
||||
|
||||
#[put("/preferences", data = "<preferences>")]
|
||||
fn put_preferences(
|
||||
db: State<DB>,
|
||||
auth: Auth,
|
||||
preferences: Json<Preferences>,
|
||||
) -> Result<(), errors::Error> {
|
||||
config::write_preferences::<DB>(&db, &auth.username, &preferences)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[post("/trigger_index")]
|
||||
fn trigger_index(
|
||||
command_sender: State<Arc<index::CommandSender>>,
|
||||
|
|
Loading…
Reference in a new issue