async fn api_get_random(elkinstance: String, elkindex: String) -> Result<Response<Body>> {
    let elkman = elk::Elk {
        instance: elkinstance,
        index: elkindex,
    };

    let output: serde_json::Value = elkman.random(1).await.unwrap();
    let response = match serde_json::to_string(&output) {
        Ok(json) => Response::builder()
            .header(header::CONTENT_TYPE, "application/json")
            .body(Body::from(json))
            .unwrap(),
        Err(_) => Response::builder()
            .status(StatusCode::INTERNAL_SERVER_ERROR)
            .body("Internal Server Error".into())
            .unwrap(),
    };
    Ok(response)
}
/// Get random value from elasticsearch, using elasticsearch's built in random function
Get random value from elasticsearch, using elasticsearch's built in random function
Get random value from elasticsearch using elasticsearch ' s built in random function
async fn api_get_random(elkinstance: String, elkindex: String) -> Result<Response<Body>> {
    let elkman = elk::Elk {
        instance: elkinstance,
        index: elkindex,
    };
    let output: serde_json::Value = elkman.random(1).await.unwrap();
    let response = match serde_json::to_string(&output) {
        Ok(json) => Response::builder()
            .header(header::CONTENT_TYPE, "application/json")
            .body(Body::from(json))
            .unwrap(),
        Err(_) => Response::builder()
            .status(StatusCode::INTERNAL_SERVER_ERROR)
            .body("Internal Server Error".into())
            .unwrap(),
    };
    Ok(response)
}
async fn api_get_random ( elkinstance : String , elkindex : String ) -> Result < Response < Body > > { let elkman = elk :: Elk { instance : elkinstance , index : elkindex , } ; let output : serde_json :: Value = elkman . random ( 1 ) . await . unwrap ( ) ; let response = match serde_json :: to_string ( & output ) { Ok ( json ) => Response :: builder ( ) . header ( header :: CONTENT_TYPE , " " ) . body ( Body :: from ( json ) ) . unwrap ( ) , Err ( _ ) => Response :: builder ( ) . status ( StatusCode :: INTERNAL_SERVER_ERROR ) . body ( " " . into ( ) ) . unwrap ( ) , } ; Ok ( response ) }
Get random value from elasticsearch, using elasticsearch's built in random function
Get random value from elasticsearch using elasticsearch ' s built in random function
elkinstance
String
elkindex
String
elkinstance
String
elkindex
String