a small relational database with user-editable schema for manual data entry
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
yopa/yopa-web/src/routes.rs

37 lines
1.1 KiB

use std::fmt::{Debug, Display};
use std::ops::{DerefMut, Deref};
use std::str::FromStr;
use actix_session::Session;
use actix_web::{HttpRequest, HttpResponse, Responder, web};
use actix_web::http::header::IntoHeaderValue;
use serde::{Deserialize, Serialize};
use yopa::{DataType, ID, Storage, StorageError, TypedValue};
use yopa::model::{ObjectModel, PropertyModel, RelationModel};
use crate::session_ext::SessionExt;
use crate::TERA;
use crate::tera_ext::TeraExt;
use crate::routes::models::relation::RelationModelDisplay;
use crate::routes::models::object::ObjectModelDisplay;
pub(crate) mod models;
pub(crate) mod objects;
#[get("/")]
pub(crate) async fn index(session: Session, store: crate::YopaStoreWrapper) -> actix_web::Result<HttpResponse> {
objects::list_inner(session, store)
.await
}
#[get("/takeout")]
pub(crate) async fn takeout(store: crate::YopaStoreWrapper) -> actix_web::Result<impl Responder> {
let rg = store.read().await;
let encoded = serde_json::to_string_pretty(rg.deref()).unwrap();
Ok(HttpResponse::Ok()
.content_type("application/json")
.body(encoded))
}