pub fn find(req: &mut Request) -> IronResult<Response> {

    // Parse the request. If the request doesn't parse properly, the request is invalid, and a 400
    // BadRequest is returned.
    let fdr = match req.get::<::bodyparser::Struct<FindDefinitionRequest>>() {
        Ok(Some(s)) => {
            trace!("definition::find parsed FindDefinitionRequest");
            s
        },
        Ok(None) => {
            trace!("definition::find failed parsing FindDefinitionRequest");
            return Ok(Response::with(status::BadRequest))
        },
        Err(err) => {
            trace!("definition::find received error while parsing FindDefinitionRequest");
            return Err(IronError::new(err, status::InternalServerError))
        }
    };

    let mutex = req.get::<::persistent::Write<EngineProvider>>().unwrap();
    let engine = mutex.lock().unwrap();
    match engine.find_definition(&fdr.context()) {
        // 200 OK; found the definition
        Ok(Some(definition)) => {
            trace!("definition::find got a match");
            let res = FindDefinitionResponse::from(definition);
            let content_type = "application/json".parse::<Mime>().unwrap();
            Ok(Response::with((content_type, status::Ok, json::encode(&res).unwrap())))
        },

        // 204 No Content; Everything went ok, but the definition was not found.
        Ok(None) => {
            trace!("definition::find did not find a match");
            Ok(Response::with(status::NoContent))
        },

        // 500 Internal Server Error; Error occurred while searching for the definition
        Err(err) => {
            trace!("definition::find encountered an error");
            Err(IronError::new(err, status::InternalServerError))
        }
    }
}
/// Given a location, return where the identifier is defined
///
/// Possible responses include
///
/// - `200 OK` the request was successful and a JSON object is returned.
/// - `204 No Content` the request was successful, but no match was found.
/// - `400 Bad Request` the request payload was malformed
/// - `500 Internal Server Error` some unexpected error occurred
Given a location, return where the identifier is defined
Possible responses include

`200 OK` the request was successful and a JSON object is returned.
`204 No Content` the request was successful, but no match was found.
`400 Bad Request` the request payload was malformed
`500 Internal Server Error` some unexpected error occurred
Given a location return where the identifier is defined Possible responses include ` 200 OK ` the request was successful and a JSON object is returned . ` 204 No Content ` the request was successful but no match was found . ` 400 Bad Request ` the request payload was malformed ` 500 Internal Server Error ` some unexpected error occurred
pub fn find(req: &mut Request) -> IronResult<Response> {
    // Parse the request. If the request doesn't parse properly, the request is invalid, and a 400
    // BadRequest is returned.
    let fdr = match req.get::<::bodyparser::Struct<FindDefinitionRequest>>() {
        Ok(Some(s)) => {
            trace!("definition::find parsed FindDefinitionRequest");
            s
        },
        Ok(None) => {
            trace!("definition::find failed parsing FindDefinitionRequest");
            return Ok(Response::with(status::BadRequest))
        },
        Err(err) => {
            trace!("definition::find received error while parsing FindDefinitionRequest");
            return Err(IronError::new(err, status::InternalServerError))
        }
    };
    let mutex = req.get::<::persistent::Write<EngineProvider>>().unwrap();
    let engine = mutex.lock().unwrap();
    match engine.find_definition(&fdr.context()) {
        // 200 OK; found the definition
        Ok(Some(definition)) => {
            trace!("definition::find got a match");
            let res = FindDefinitionResponse::from(definition);
            let content_type = "application/json".parse::<Mime>().unwrap();
            Ok(Response::with((content_type, status::Ok, json::encode(&res).unwrap())))
        },
        // 204 No Content; Everything went ok, but the definition was not found.
        Ok(None) => {
            trace!("definition::find did not find a match");
            Ok(Response::with(status::NoContent))
        },
        // 500 Internal Server Error; Error occurred while searching for the definition
        Err(err) => {
            trace!("definition::find encountered an error");
            Err(IronError::new(err, status::InternalServerError))
        }
    }
}
pub fn find ( req : & mut Request ) -> IronResult < Response > { // Parse the request. If the request doesn't parse properly, the request is invalid, and a 400 // BadRequest is returned. let fdr = match req . get :: < :: bodyparser :: Struct < FindDefinitionRequest > > ( ) { Ok ( Some ( s ) ) => { trace ! ( " " ) ; s } , Ok ( None ) => { trace ! ( " " ) ; return Ok ( Response :: with ( status :: BadRequest ) ) } , Err ( err ) => { trace ! ( " " ) ; return Err ( IronError :: new ( err , status :: InternalServerError ) ) } } ; let mutex = req . get :: < :: persistent :: Write < EngineProvider > > ( ) . unwrap ( ) ; let engine = mutex . lock ( ) . unwrap ( ) ; match engine . find_definition ( & fdr . context ( ) ) { // 200 OK; found the definition Ok ( Some ( definition ) ) => { trace ! ( " " ) ; let res = FindDefinitionResponse :: from ( definition ) ; let content_type = " " . parse :: < Mime > ( ) . unwrap ( ) ; Ok ( Response :: with ( ( content_type , status :: Ok , json :: encode ( & res ) . unwrap ( ) ) ) ) } , // 204 No Content; Everything went ok, but the definition was not found. Ok ( None ) => { trace ! ( " " ) ; Ok ( Response :: with ( status :: NoContent ) ) } , // 500 Internal Server Error; Error occurred while searching for the definition Err ( err ) => { trace ! ( " " ) ; Err ( IronError :: new ( err , status :: InternalServerError ) ) } } }
Given a location, return where the identifier is defined
Possible responses include
Given a location return where the identifier is defined Possible responses include
req
&mut Request
req
&mut Request