pub async fn show(config: web::Data<config::Config>,
                  req: HttpRequest)
                  -> actix_web::Result<HttpResponse> {
    // A JSON pointer of "" means "everything". Pointers starting with
    // "/" describe paths into the structure. We'll chop off any
    // trailing "/" since that will end up looking for an item with a
    // key of "", which we're just not going to deal with.
    let pointer = match req.match_info().get("path") {
        None | Some("") => Cow::Borrowed(""),
        Some(path) => Cow::Owned(format!("/{}", path.trim_end_matches('/'))),
    };
    let json = read_json(&config.render_context_file).map_err(actix_web::error::ErrorBadRequest)?;
    if let Some(value) = json.pointer(&pointer) {
        Ok(HttpResponse::Ok().json(value))
    } else {
        Ok(HttpResponse::NotFound().finish())
    }
}
// Required by actix-web API
Required by actix-web API
Required by actix - web API
pub async fn show(config: web::Data<config::Config>,
                  req: HttpRequest)
                  -> actix_web::Result<HttpResponse> {
    // A JSON pointer of "" means "everything". Pointers starting with
    // "/" describe paths into the structure. We'll chop off any
    // trailing "/" since that will end up looking for an item with a
    // key of "", which we're just not going to deal with.
    let pointer = match req.match_info().get("path") {
        None | Some("") => Cow::Borrowed(""),
        Some(path) => Cow::Owned(format!("/{}", path.trim_end_matches('/'))),
    };
    let json = read_json(&config.render_context_file).map_err(actix_web::error::ErrorBadRequest)?;
    if let Some(value) = json.pointer(&pointer) {
        Ok(HttpResponse::Ok().json(value))
    } else {
        Ok(HttpResponse::NotFound().finish())
    }
}
pub async fn show ( config : web :: Data < config :: Config > , req : HttpRequest ) -> actix_web :: Result < HttpResponse > { // A JSON pointer of "" means "everything". Pointers starting with // "/" describe paths into the structure. We'll chop off any // trailing "/" since that will end up looking for an item with a // key of "", which we're just not going to deal with. let pointer = match req . match_info ( ) . get ( " " ) { None | Some ( " " ) => Cow :: Borrowed ( " " ) , Some ( path ) => Cow :: Owned ( format ! ( " " path trim_end_matches ( '/' ) ) ) , } ; let json = read_json ( & config . render_context_file ) . map_err ( actix_web :: error :: ErrorBadRequest ) ? ; if let Some ( value ) = json . pointer ( & pointer ) { Ok ( HttpResponse :: Ok ( ) . json ( value ) ) } else { Ok ( HttpResponse :: NotFound ( ) . finish ( ) ) } }
Required by actix-web API
Required by actix - web API
config
web::Data<config::Config>
req
HttpRequest