fn req_obj_put(
    m_state: web::Data<Arc<Mutex<ServerState>>>,
    req: HttpRequest,
    (path, body): (web::Path<(String, String)>, web::Bytes),
) -> Result<HttpResponse> {
    // lock runtime-live state data
    let mut state = m_state.lock().unwrap();
    if state.debug {
        println!("{:?}", req);
    }

    // lookup database index by name (path elem 0)
    let idx: usize;
    match state.name_idx.get(&path.0) {
        None => return err_not_found(),
        Some(r_idx) => idx = *r_idx,
    }

    // attempt to store record in db, based on key (path elem 1)
    match state.dbs[idx].db.put(path.1.as_bytes(), &body.to_vec()) {
        Ok(_optval) => ok_json(json!({"result": true})),
        Err(_e) => err_500(), // db: error
    }
}
/// PUT data item. key in URI path, value in HTTP payload.
PUT data item. key in URI path, value in HTTP payload.
PUT data item . key in URI path value in HTTP payload .
fn req_obj_put(
    m_state: web::Data<Arc<Mutex<ServerState>>>,
    req: HttpRequest,
    (path, body): (web::Path<(String, String)>, web::Bytes),
) -> Result<HttpResponse> {
    // lock runtime-live state data
    let mut state = m_state.lock().unwrap();
    if state.debug {
        println!("{:?}", req);
    }
    // lookup database index by name (path elem 0)
    let idx: usize;
    match state.name_idx.get(&path.0) {
        None => return err_not_found(),
        Some(r_idx) => idx = *r_idx,
    }
    // attempt to store record in db, based on key (path elem 1)
    match state.dbs[idx].db.put(path.1.as_bytes(), &body.to_vec()) {
        Ok(_optval) => ok_json(json!({"result": true})),
        Err(_e) => err_500(), // db: error
    }
}
fn req_obj_put ( m_state : web :: Data < Arc < Mutex < ServerState > > > , req : HttpRequest , ( path , body ) : ( web :: Path < ( String , String ) > , web :: Bytes ) , ) -> Result < HttpResponse > { // lock runtime-live state data let mut state = m_state . lock ( ) . unwrap ( ) ; if state . debug { println ! ( " " req ) ; } // lookup database index by name (path elem 0) let idx : usize ; match state . name_idx . get ( & path . 0 ) { None => return err_not_found ( ) , Some ( r_idx ) => idx = * r_idx , } // attempt to store record in db, based on key (path elem 1) match state . dbs [ idx ] . db . put ( path . 1 . as_bytes ( ) , & body . to_vec ( ) ) { Ok ( _optval ) => ok_json ( json ! ( { " " true } ) ) , Err ( _e ) => err_500 ( ) , // db: error } }
PUT data item.
PUT data item .
m_state
web::Data<Arc<Mutex<ServerState>>>
req
(web::Path<(String, String)>, web::Bytes)
m_state
web::Data<Arc<Mutex<ServerState>>>
req
(web::Path<(String, String)>, web::Bytes)