fn req_obj_delete(
    m_state: web::Data<Arc<Mutex<ServerState>>>,
    req: HttpRequest,
    path: web::Path<(String, String)>,
) -> 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 remove record from db, based on key (path elem 1)
    match state.dbs[idx].db.del(path.1.as_bytes()) {
        Ok(optval) => match optval {
            true => ok_json(json!({"result": true})),
            false => err_not_found(), // db: value not found
        },
        Err(_e) => err_500(), // db: error
    }
}
/// DELETE data item.  key in URI path.  return ok as json response
DELETE data item.  key in URI path.  return ok as json response
DELETE data item . key in URI path . return ok as json response
fn req_obj_delete(
    m_state: web::Data<Arc<Mutex<ServerState>>>,
    req: HttpRequest,
    path: web::Path<(String, String)>,
) -> 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 remove record from db, based on key (path elem 1)
    match state.dbs[idx].db.del(path.1.as_bytes()) {
        Ok(optval) => match optval {
            true => ok_json(json!({"result": true})),
            false => err_not_found(), // db: value not found
        },
        Err(_e) => err_500(), // db: error
    }
}
fn req_obj_delete ( m_state : web :: Data < Arc < Mutex < ServerState > > > , req : HttpRequest , path : web :: Path < ( String , String ) > , ) -> 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 remove record from db, based on key (path elem 1) match state . dbs [ idx ] . db . del ( path . 1 . as_bytes ( ) ) { Ok ( optval ) => match optval { true => ok_json ( json ! ( { " " true } ) ) , false => err_not_found ( ) , // db: value not found } , Err ( _e ) => err_500 ( ) , // db: error } }
DELETE data item.
DELETE data item .
m_state
web::Data<Arc<Mutex<ServerState>>>
req
HttpRequest
path
web::Path<(String, String)>
m_state
web::Data<Arc<Mutex<ServerState>>>
req
HttpRequest
path
web::Path<(String, String)>