async fn api_remove_key(req: Request<Body>, dblocation: String) -> Result<Response<Body>> {
    let whole_body = hyper::body::aggregate(req).await?;
    let mut data: serde_json::Value = serde_json::from_reader(whole_body.reader())?;
    if data["key"] == json!(null) {
        data["error"] = serde_json::Value::from("no key field!");
        let json = serde_json::to_string(&data)?;
        let response = Response::builder()
            .status(StatusCode::OK)
            .header(header::CONTENT_TYPE, "application/json")
            .body(Body::from(json))?;
        return Ok(response);
    }
    let removekey = &data["key"];

    let dbin = database::Database {
        filelocation: dblocation,
    }; //find(title);

    let out = dbin.remove(removekey.to_string());
    data["Result"] = serde_json::Value::from(out);
    let json = serde_json::to_string(&data)?;
    let response = Response::builder()
        .status(StatusCode::OK)
        .header(header::CONTENT_TYPE, "application/json")
        .body(Body::from(json))?;
    Ok(response)
}
/// remove a key value from the cache
remove a key value from the cache
remove a key value from the cache
async fn api_remove_key(req: Request<Body>, dblocation: String) -> Result<Response<Body>> {
    let whole_body = hyper::body::aggregate(req).await?;
    let mut data: serde_json::Value = serde_json::from_reader(whole_body.reader())?;
    if data["key"] == json!(null) {
        data["error"] = serde_json::Value::from("no key field!");
        let json = serde_json::to_string(&data)?;
        let response = Response::builder()
            .status(StatusCode::OK)
            .header(header::CONTENT_TYPE, "application/json")
            .body(Body::from(json))?;
        return Ok(response);
    }
    let removekey = &data["key"];
    let dbin = database::Database {
        filelocation: dblocation,
    }; //find(title);
    let out = dbin.remove(removekey.to_string());
    data["Result"] = serde_json::Value::from(out);
    let json = serde_json::to_string(&data)?;
    let response = Response::builder()
        .status(StatusCode::OK)
        .header(header::CONTENT_TYPE, "application/json")
        .body(Body::from(json))?;
    Ok(response)
}
async fn api_remove_key ( req : Request < Body > , dblocation : String ) -> Result < Response < Body > > { let whole_body = hyper :: body :: aggregate ( req ) . await ? ; let mut data : serde_json :: Value = serde_json :: from_reader ( whole_body . reader ( ) ) ? ; if data [ " " ] == json ! ( null ) { data [ " " ] = serde_json :: Value :: from ( " " ) ; let json = serde_json :: to_string ( & data ) ? ; let response = Response :: builder ( ) . status ( StatusCode :: OK ) . header ( header :: CONTENT_TYPE , " " ) . body ( Body :: from ( json ) ) ? ; return Ok ( response ) ; } let removekey = & data [ " " ] ; let dbin = database :: Database { filelocation : dblocation , } ; //find(title); let out = dbin . remove ( removekey . to_string ( ) ) ; data [ " " ] = serde_json :: Value :: from ( out ) ; let json = serde_json :: to_string ( & data ) ? ; let response = Response :: builder ( ) . status ( StatusCode :: OK ) . header ( header :: CONTENT_TYPE , " " ) . body ( Body :: from ( json ) ) ? ; Ok ( response ) }
remove a key value from the cache
remove a key value from the cache
req
Request<Body>
dblocation
String
req
Request<Body>
dblocation
String