diff --git a/frameworks/Rust/anansi/Cargo.toml b/frameworks/Rust/anansi/Cargo.toml deleted file mode 100644 index a717e96e70b..00000000000 --- a/frameworks/Rust/anansi/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[workspace] -members = [ - ".", -] - -[package] -name = "tfb-anansi" -version = "0.1.0" -edition = "2021" - -[features] -raw = [] - -[dependencies] -anansi = { git = "https://github.com/saru-tora/anansi", rev = "c350a23", features = ["postgres", "minimal", "redis"] } -async-trait = "0.1.57" -rand = "0.8.4" -serde = "1" -serde_json = "1" -tokio-postgres = "0.7.7" - -[profile.release] -lto = true -opt-level = 3 -codegen-units = 1 diff --git a/frameworks/Rust/anansi/README.md b/frameworks/Rust/anansi/README.md deleted file mode 100755 index ebddef843ca..00000000000 --- a/frameworks/Rust/anansi/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# [Anansi](https://saru-tora.github.io/anansi/) Benchmarking Test - -Anansi is a simple full-stack web framework for Rust. - -### Test Type Implementation Source Code - -All tests can be found in: src/hello/world/ - -## Test URLs -### JSON - -http://localhost:8080/json - -### PLAINTEXT - -http://localhost:8080/plaintext - -### DB - -http://localhost:8080/db - -### QUERY - -http://localhost:8080/query?queries= - -### CACHED QUERY - -http://localhost:8080/cached_query?queries= - -### UPDATE - -http://localhost:8080/update?queries= - -### FORTUNES - -http://localhost:8080/fortunes diff --git a/frameworks/Rust/anansi/anansi-raw.dockerfile b/frameworks/Rust/anansi/anansi-raw.dockerfile deleted file mode 100644 index 96c284a8b7a..00000000000 --- a/frameworks/Rust/anansi/anansi-raw.dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM rust:1.64 - -ADD ./ /anansi -WORKDIR /anansi - -RUN cargo clean -RUN RUSTFLAGS="-C target-cpu=native" cargo build --release --features raw - -EXPOSE 8080 - -CMD RUST_LOG=off ./target/release/tfb-anansi 0.0.0.0:8080 diff --git a/frameworks/Rust/anansi/anansi.dockerfile b/frameworks/Rust/anansi/anansi.dockerfile deleted file mode 100644 index bf6f7596193..00000000000 --- a/frameworks/Rust/anansi/anansi.dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM rust:1.64 - -RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends redis-server - -ADD ./ /anansi -WORKDIR /anansi - -RUN cargo clean -RUN RUSTFLAGS="-C target-cpu=native" cargo build --release - -EXPOSE 8080 - -ENV RUST_LOG=off -CMD service redis-server start && ./target/release/tfb-anansi 0.0.0.0:8080 diff --git a/frameworks/Rust/anansi/benchmark_config.json b/frameworks/Rust/anansi/benchmark_config.json deleted file mode 100755 index dd1c17b71bd..00000000000 --- a/frameworks/Rust/anansi/benchmark_config.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "framework": "anansi", - "tests": [ - { - "default": { - "json_url": "/json", - "plaintext_url": "/plaintext", - "db_url": "/db", - "fortune_url": "/fortunes", - "query_url": "/queries?q=", - "update_url": "/updates?q=", - "cached_query_url": "/cached-queries?q=", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "postgres", - "framework": "Anansi", - "language": "Rust", - "flavor": "None", - "orm": "Full", - "platform": "None", - "webserver": "hyper", - "os": "Linux", - "database_os": "Linux", - "display_name": "Anansi [minimal]", - "notes": "", - "versus": "None" - }, - "raw": { - "db_url": "/db", - "fortune_url": "/fortunes", - "query_url": "/queries?q=", - "update_url": "/updates?q=", - "cached_query_url": "/cached-queries?q=", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "postgres", - "framework": "Anansi", - "language": "Rust", - "flavor": "None", - "orm": "Raw", - "platform": "None", - "webserver": "hyper", - "os": "Linux", - "database_os": "Linux", - "display_name": "Anansi [minimal, raw]", - "notes": "", - "versus": "None" - } - } - ] -} diff --git a/frameworks/Rust/anansi/settings.toml b/frameworks/Rust/anansi/settings.toml deleted file mode 100644 index 6089347e428..00000000000 --- a/frameworks/Rust/anansi/settings.toml +++ /dev/null @@ -1,18 +0,0 @@ -secret_key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -login_url = "/login" -smtp_relay = "" -smtp_username = "" -smtp_password = "" - -[caches] - -[caches.default] -location = "redis://127.0.0.1/" - -[databases] - -[databases.default] -name = "hello_world" -user = "benchmarkdbuser" -password = "benchmarkdbpass" -address = "tfb-database" diff --git a/frameworks/Rust/anansi/src/hello/middleware.rs b/frameworks/Rust/anansi/src/hello/middleware.rs deleted file mode 100644 index be369cb827d..00000000000 --- a/frameworks/Rust/anansi/src/hello/middleware.rs +++ /dev/null @@ -1,94 +0,0 @@ -use std::fmt::{self, Write}; -use std::sync::Arc; -use anansi::db::postgres::{PgDbPool, PgDbRow, PgDbRowVec, PgStatement}; - -#[macro_export] -macro_rules! impl_pg { - () => { - #[async_trait::async_trait] - impl crate::hello::middleware::Pg for HttpRequest { - async fn get_world(&self) -> anansi::web::Result { - use anansi::web::BaseRequest; - self.raw().app_state().stmt.0.world.fetch_one(&[&Self::random_num()], self.raw().pool()).await - } - async fn update_worlds(&self, n: usize, params: &[&(dyn tokio_postgres::types::ToSql + Sync)]) -> anansi::web::Result<()> { - use anansi::web::BaseRequest; - self.raw().app_state().stmt.0.updates[n].execute(params, self.raw().pool()).await - } - async fn get_fortunes(&self) -> anansi::web::Result { - use anansi::web::BaseRequest; - self.raw().app_state().stmt.0.fortune.fetch_all(&[], self.raw().pool()).await - } - } - impl crate::hello::middleware::AsStmt for AppData { - fn as_stmt(&self) -> &crate::hello::middleware::Stmt { - &self.stmt - } - } - } -} - -fn update_statement(num: u16) -> String { - let mut pl = 1; - let mut q = "UPDATE world SET randomnumber = CASE id ".to_string(); - for _ in 1..=num { - let _ = write!(q, "WHEN ${} THEN ${} ", pl, pl + 1); - pl += 2; - } - - q.push_str("ELSE randomnumber END WHERE id IN ("); - - for _ in 1..=num { - let _ = write!(q, "${},", pl); - pl += 1; - } - - q.pop(); - q.push(')'); - q -} - -#[derive(Clone)] -pub struct Stmt(pub Arc); - -impl fmt::Debug for Stmt { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Stmt") - .finish() - } -} - -impl Stmt { - pub async fn new(pool: &PgDbPool) -> anansi::web::Result { - let mut updates = vec![]; - for n in 1..=500 { - updates.push(PgStatement::new(&update_statement(n), pool).await?); - } - Ok(Self(Arc::new(State { - world: PgStatement::new("SELECT * FROM world WHERE id = $1", pool).await?, - updates, - fortune: PgStatement::new("SELECT * FROM fortune", pool).await?, - }))) - } -} - -pub struct State { - pub world: PgStatement, - pub updates: Vec, - pub fortune: PgStatement, -} - -pub trait AsStmt { - fn as_stmt(&self) -> &Stmt; -} - -#[async_trait::async_trait] -pub trait Pg { - fn random_num() -> i32 { - use rand::Rng; - rand::thread_rng().gen_range(1..=10_000) - } - async fn get_world(&self) -> anansi::web::Result; - async fn update_worlds(&self, n: usize, params: &[&(dyn tokio_postgres::types::ToSql + Sync)]) -> anansi::web::Result<()>; - async fn get_fortunes(&self) -> anansi::web::Result; -} diff --git a/frameworks/Rust/anansi/src/hello/migrations/mod.rs b/frameworks/Rust/anansi/src/hello/migrations/mod.rs deleted file mode 100644 index 72ca3a1f046..00000000000 --- a/frameworks/Rust/anansi/src/hello/migrations/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -use anansi::migrations::prelude::*; - -local_migrations! {} \ No newline at end of file diff --git a/frameworks/Rust/anansi/src/hello/mod.rs b/frameworks/Rust/anansi/src/hello/mod.rs deleted file mode 100644 index 74ca45e2a9d..00000000000 --- a/frameworks/Rust/anansi/src/hello/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod records; -pub mod migrations; - -pub const APP_NAME: &'static str = "hello"; -pub mod world; - -#[cfg(feature = "raw")] -pub mod middleware; diff --git a/frameworks/Rust/anansi/src/hello/records.rs b/frameworks/Rust/anansi/src/hello/records.rs deleted file mode 100644 index 6dc93a9c95c..00000000000 --- a/frameworks/Rust/anansi/src/hello/records.rs +++ /dev/null @@ -1,48 +0,0 @@ -#![allow(non_snake_case)] -use async_trait::async_trait; -use anansi::web::{Result, BaseRequest}; -use anansi::record; -use anansi::records::{Relate, Int, Text, random_int}; -use serde::Serialize; - -#[record(table_name = "World")] -#[derive(Serialize)] -pub struct World { - #[field(primary_key = "true", default_fn = "random_int")] - pub id: Int, - pub randomNumber: Int, -} - -#[async_trait] -impl Relate for World { - async fn on_save(&self, _req: &mut R) -> Result<()> { - unimplemented!(); - } - async fn on_delete(&self, _req: &R) -> Result<()> { - unimplemented!(); - } -} - -#[record(table_name = "Fortune")] -pub struct Fortune { - #[field(primary_key = "true", default_fn = "random_int")] - pub id: Int, - pub message: Text, -} - -#[cfg(not(feature = "raw"))] -impl Fortune { - pub fn additional() -> Self { - Self {id: Int::new(0), message: Text::from("Additional fortune added at request time.".to_string())} - } -} - -#[async_trait] -impl Relate for Fortune { - async fn on_save(&self, _req: &mut R) -> Result<()> { - unimplemented!(); - } - async fn on_delete(&self, _req: &R) -> Result<()> { - unimplemented!(); - } -} diff --git a/frameworks/Rust/anansi/src/hello/world/mod.rs b/frameworks/Rust/anansi/src/hello/world/mod.rs deleted file mode 100644 index 2d3508e5707..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(not(feature = "raw"))] -pub mod views; -#[cfg(feature = "raw")] -pub mod raw; -pub mod util; diff --git a/frameworks/Rust/anansi/src/hello/world/raw.rs b/frameworks/Rust/anansi/src/hello/world/raw.rs deleted file mode 100644 index 6199bf0fb2e..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/raw.rs +++ /dev/null @@ -1,110 +0,0 @@ -use crate::prelude::*; -use crate::hello::middleware::Pg; -use serde::Serialize; -use anansi::check; -use super::util::get_query; -use rand::Rng; -use tokio_postgres::types::ToSql; - -fn random_num() -> i32 { - rand::thread_rng().gen_range(1..=10_000) -} - -#[derive(Copy, Clone, Serialize, Debug)] -pub struct World { - id: i32, - randomnumber: i32, -} - -#[derive(Serialize, Debug)] -pub struct Fortune<'a> { - id: i32, - message: &'a str, -} - -#[base_view] -fn base(_req: &mut R) -> Result {} - -#[viewer] -impl WorldView { - async fn one_world(req: &R) -> Result { - let row = req.get_world().await?; - let world = World { - id: row.get_i32(0), - randomnumber: row.get_i32(1), - }; - Ok(world) - } - async fn get_worlds(req: &R) -> Result> { - let q = get_query(req.params()); - let mut worlds = Vec::with_capacity(q as usize); - for _ in 0..q { - let world = Self::one_world(req).await?; - worlds.push(world); - } - Ok(worlds) - } - #[check(Site::is_visitor)] - pub async fn db(req: &mut R) -> Result { - let world = Self::one_world(req).await?; - Response::json(&world) - } - #[check(Site::is_visitor)] - pub async fn queries(req: &mut R) -> Result { - let worlds = Self::get_worlds(req).await?; - Response::json(&worlds) - } - #[view(Site::is_visitor)] - pub async fn raw_fortunes(req: &mut R) -> Result { - let title = "Fortunes"; - let rows = req.get_fortunes().await?; - let mut fortunes = Vec::with_capacity(rows.len() + 1); - fortunes.push(Fortune { - id: 0, - message: "Additional fortune added at request time.", - }); - fortunes.extend(rows.iter().map(|row| Fortune { - id: row.get(0), - message: row.get(1), - })); - fortunes.sort_by(|it, next| it.message.cmp(&next.message)); - } - #[check(Site::is_visitor)] - pub async fn updates(req: &mut R) -> Result { - let q = get_query(req.params()) as usize; - let mut worlds = Vec::with_capacity(q); - let mut params: Vec<&(dyn ToSql + Sync)> = Vec::with_capacity(q * 3); - for _ in 0..q { - let row = req.get_world().await?; - let world = World { - id: row.get_i32(0), - randomnumber: random_num(), - }; - worlds.push(world); - } - for world in &worlds { - params.push(&world.id); - params.push(&world.randomnumber); - } - for world in &worlds { - params.push(&world.id); - } - req.update_worlds(q - 1, params.as_slice()).await?; - Response::json(&worlds) - } - #[check(Site::is_visitor)] - pub async fn cached_queries(req: &mut R) -> Result { - let q = get_query(req.params()); - let mut ids = vec![]; - for _ in 0..q { - ids.push(random_num().to_string()); - } - let mut worlds = vec!['[' as u8]; - for mut world in req.cache().get_many(ids).await? { - worlds.append(&mut world); - } - worlds.pop(); - worlds.push(']' as u8); - Response::json_bytes(worlds) - } -} diff --git a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/base.in b/frameworks/Rust/anansi/src/hello/world/templates/.parsed/base.in deleted file mode 100644 index 0473720779d..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/base.in +++ /dev/null @@ -1,9 +0,0 @@ -{let mut _c = String::new();_c.push_str(" - - - ");_c.push_str(&_base_args._title);_c.push_str(" - - - ");_c.push_str(&_base_args._content);_c.push_str(" - -");_c.into_bytes()} \ No newline at end of file diff --git a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/base_args.in b/frameworks/Rust/anansi/src/hello/world/templates/.parsed/base_args.in deleted file mode 100644 index 9ad5b91f42b..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/base_args.in +++ /dev/null @@ -1 +0,0 @@ -pub struct Args {pub _title: String,pub _content: String,}impl anansi::cache::Cacheable for Args {fn to_bytes(&self) -> Vec {let mut v = vec![];v.append(&mut self._title.len().to_ne_bytes().to_vec());v.append(&mut self._title.as_bytes().to_vec());v.append(&mut self._content.len().to_ne_bytes().to_vec());v.append(&mut self._content.as_bytes().to_vec());v} fn from_bytes(mut __b: Vec) -> anansi::web::Result {let mut buf = __b.split_off(8); let l = usize::from_ne_bytes(__b.try_into().unwrap()); let mut __b = buf.split_off(l); let _title = String::from_utf8(buf)?;let mut buf = __b.split_off(8); let l = usize::from_ne_bytes(__b.try_into().unwrap()); let mut __b = buf.split_off(l); let _content = String::from_utf8(buf)?;Ok(Self {_title, _content, })}} impl Args {pub fn new() -> Self {Self {_title: String::new(), _content: String::new(), }}} \ No newline at end of file diff --git a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/fortunes.in b/frameworks/Rust/anansi/src/hello/world/templates/.parsed/fortunes.in deleted file mode 100644 index 7cf8984f743..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/fortunes.in +++ /dev/null @@ -1,6 +0,0 @@ -{_args._title = {let mut _c = String::new();_c.push_str("");_c.push_str(&anansi::web::html_escape(&format!("{}", title)));_c.push_str(""); _c};_args._content = {let mut _c = String::new();_c.push_str(" - - ");for fortune in fortunes {_c.push_str(" - - ");}_c.push_str(" -
idmessage
");_c.push_str(&anansi::web::html_escape(&format!("{}", fortune.pk())));_c.push_str("");_c.push_str(&anansi::web::html_escape(&format!("{}", fortune.message)));_c.push_str("
"); _c};_args} \ No newline at end of file diff --git a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/index.in b/frameworks/Rust/anansi/src/hello/world/templates/.parsed/index.in deleted file mode 100644 index 17b9c49d56b..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/index.in +++ /dev/null @@ -1 +0,0 @@ -{_args._title = {let mut _c = String::new();_c.push_str("");_c.push_str(&anansi::web::html_escape(&format!("{}", title)));_c.push_str(""); _c};_args._content = {let mut _c = String::new();_c.push_str("

");_c.push_str(&anansi::web::html_escape(&format!("{}", title)));_c.push_str("

"); _c};_args} \ No newline at end of file diff --git a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/raw_fortunes.in b/frameworks/Rust/anansi/src/hello/world/templates/.parsed/raw_fortunes.in deleted file mode 100644 index 83c5b13e6cf..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/.parsed/raw_fortunes.in +++ /dev/null @@ -1,4 +0,0 @@ -{_args._content = {let mut _c = String::new();_c.push_str(""); -for fortune in fortunes {_c.push_str(&format!("");} -_c.push_str("
idmessage
{}", fortune.id));anansi::web::html_escape2(&mut _c, fortune.message);_c.push_str("
"); _c}; -_args._title = {let mut _c = String::new();_c.push_str(&format!("{}", title)); _c};_args} diff --git a/frameworks/Rust/anansi/src/hello/world/templates/base.rs.html b/frameworks/Rust/anansi/src/hello/world/templates/base.rs.html deleted file mode 100644 index 440d37a95eb..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/base.rs.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - @block title - - - @block content - - diff --git a/frameworks/Rust/anansi/src/hello/world/templates/fortunes.rs.html b/frameworks/Rust/anansi/src/hello/world/templates/fortunes.rs.html deleted file mode 100644 index 0d4e369792a..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/fortunes.rs.html +++ /dev/null @@ -1,10 +0,0 @@ -@block title {@title} - -@block content { - - - @for fortune in fortunes { - - } -
idmessage
@fortune.pk()@fortune.message
-} diff --git a/frameworks/Rust/anansi/src/hello/world/templates/raw_fortunes.rs.html b/frameworks/Rust/anansi/src/hello/world/templates/raw_fortunes.rs.html deleted file mode 100644 index 22edc654ba9..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/templates/raw_fortunes.rs.html +++ /dev/null @@ -1,10 +0,0 @@ -@block title {@unescape title} - -@block content { - - - @for fortune in fortunes { - - } -
idmessage
@unescape fortune.id@fortune.message
-} diff --git a/frameworks/Rust/anansi/src/hello/world/util.rs b/frameworks/Rust/anansi/src/hello/world/util.rs deleted file mode 100644 index 8e8998f2b1f..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/util.rs +++ /dev/null @@ -1,16 +0,0 @@ -use anansi::web::Parameters; - -pub fn get_query(params: &Parameters) -> i16 { - if let Ok(q) = params.get("q") { - if let Ok(q) = q.parse() { - if q > 1 { - return if q <= 500 { - q - } else { - 500 - }; - } - } - } - 1 -} diff --git a/frameworks/Rust/anansi/src/hello/world/views.rs b/frameworks/Rust/anansi/src/hello/world/views.rs deleted file mode 100644 index c75b2fcd4cb..00000000000 --- a/frameworks/Rust/anansi/src/hello/world/views.rs +++ /dev/null @@ -1,90 +0,0 @@ -use crate::prelude::*; -use anansi::cache::prelude::*; -use anansi::records::Int; -use super::super::records::{World, Fortune}; -use super::util::get_query; -use serde::Serialize; -use anansi::{check, raw_bulk_update}; -use rand::Rng; - -fn random_i32() -> i32 { - rand::thread_rng().gen_range(1..=10_000) -} - -fn random_int() -> Int { - Int::new(random_i32()) -} - -#[derive(Serialize)] -struct Message { - message: &'static str, -} - -#[base_view] -fn base(_req: &mut R) -> Result {} - -#[viewer] -impl WorldView { - #[check(Site::is_visitor)] - pub async fn json(req: &mut R) -> Result { - let message = Message {message: "Hello, World!"}; - Response::json(&message) - } - async fn get_world(req: &R) -> Result { - World::find(random_int()).get(req).await - } - async fn get_worlds(req: &R) -> Result> { - let q = get_query(req.params()); - let mut worlds = Vec::with_capacity(q as usize); - for _ in 0..q { - let world = Self::get_world(req).await?; - worlds.push(world); - } - Ok(worlds) - } - #[check(Site::is_visitor)] - pub async fn db(req: &mut R) -> Result { - let world = Self::get_world(req).await?; - Response::json(&world) - } - #[check(Site::is_visitor)] - pub async fn queries(req: &mut R) -> Result { - let worlds = Self::get_worlds(req).await?; - Response::json(&worlds) - } - #[view(Site::is_visitor)] - pub async fn fortunes(req: &mut R) -> Result { - let title = "Fortunes"; - let mut fortunes = Fortune::get_all().query(req).await?; - fortunes.push(Fortune::additional()); - fortunes.sort_by(|it, next| it.message.cmp(&next.message)); - } - #[check(Site::is_visitor)] - pub async fn updates(req: &mut R) -> Result { - let mut worlds = Self::get_worlds(req).await?; - for world in &mut worlds { - world.randomNumber = random_int(); - } - raw_bulk_update!(req, World, &worlds, randomNumber).await?; - Response::json(&worlds) - } - #[check(Site::is_visitor)] - pub async fn plaintext(req: &mut R) -> Result { - Ok(Response::text("Hello, World!".to_string())) - } - #[check(Site::is_visitor)] - pub async fn cached_queries(req: &mut R) -> Result { - let q = get_query(req.params()); - let mut ids = vec![]; - for _ in 0..q { - ids.push(random_i32().to_string()); - } - let mut worlds = vec!['[' as u8]; - for mut world in req.cache().get_many(ids).await? { - worlds.append(&mut world); - } - worlds.pop(); - worlds.push(']' as u8); - Response::json_bytes(worlds) - } -} diff --git a/frameworks/Rust/anansi/src/http_errors/500.html b/frameworks/Rust/anansi/src/http_errors/500.html deleted file mode 100644 index 1c14f7cd7f3..00000000000 --- a/frameworks/Rust/anansi/src/http_errors/500.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - 500 Internal Server Error - - -

Internal Server Error

-

Sorry, something went wrong.

- - diff --git a/frameworks/Rust/anansi/src/http_errors/mod.rs b/frameworks/Rust/anansi/src/http_errors/mod.rs deleted file mode 100644 index 38b44033152..00000000000 --- a/frameworks/Rust/anansi/src/http_errors/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod views; diff --git a/frameworks/Rust/anansi/src/http_errors/templates/.parsed/not_found.in b/frameworks/Rust/anansi/src/http_errors/templates/.parsed/not_found.in deleted file mode 100644 index c13f6730bf5..00000000000 --- a/frameworks/Rust/anansi/src/http_errors/templates/.parsed/not_found.in +++ /dev/null @@ -1,11 +0,0 @@ -{let mut _c = String::new();_c.push_str(" - - - - Not Found - - -

404

-

Page not found.

- -");_c.into_bytes()} \ No newline at end of file diff --git a/frameworks/Rust/anansi/src/http_errors/templates/not_found.rs.html b/frameworks/Rust/anansi/src/http_errors/templates/not_found.rs.html deleted file mode 100644 index eaf9a979ee7..00000000000 --- a/frameworks/Rust/anansi/src/http_errors/templates/not_found.rs.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Not Found - - -

404

-

Page not found.

- - diff --git a/frameworks/Rust/anansi/src/http_errors/views.rs b/frameworks/Rust/anansi/src/http_errors/views.rs deleted file mode 100644 index 04872858818..00000000000 --- a/frameworks/Rust/anansi/src/http_errors/views.rs +++ /dev/null @@ -1,12 +0,0 @@ -use anansi::{check, viewer, render}; -use anansi::web::{Result, Response}; -use anansi::site::Site; -use crate::project::Request; - -#[viewer] -impl ErrorView { - #[check(Site::is_visitor)] - pub async fn not_found(_req: &mut R) -> Result { - render!("not_found") - } -} diff --git a/frameworks/Rust/anansi/src/main.rs b/frameworks/Rust/anansi/src/main.rs deleted file mode 100644 index 24e3fd87292..00000000000 --- a/frameworks/Rust/anansi/src/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -use anansi::*; - -mod urls; -mod project; -mod http_errors; -mod hello; - -apps! { - hello, -} - -app_statics! {} - -min_main!(server, { - use anansi::cache::prelude::*; - use hello::records::World; - use anansi::records::Record; - use anansi::db::AsDb; - let worlds = World::get_all().raw_query(server.app_data.as_db()).await.expect("problem fetching worlds"); - let mut items = vec![]; - for world in worlds { - let id = world.pk().to_string(); - let mut bytes = serde_json::to_vec(&world).expect("problem serializing world"); - bytes.push(',' as u8); - items.push((id, bytes)); - } - server.cache.set_many(&items).await.expect("problem caching world"); -}); diff --git a/frameworks/Rust/anansi/src/project.rs b/frameworks/Rust/anansi/src/project.rs deleted file mode 100644 index 074460a6b46..00000000000 --- a/frameworks/Rust/anansi/src/project.rs +++ /dev/null @@ -1,62 +0,0 @@ -use anansi::project::prelude::*; -use crate::app_migrations; - -#[cfg(feature = "raw")] -use super::hello::middleware::Stmt; - -#[cfg(feature = "raw")] -use crate::impl_pg; - -#[cfg(feature = "raw")] -app_cache!(local); - -#[cfg(not(feature = "raw"))] -app_cache!(redis); - -database!(postgres); - -#[cfg(feature = "raw")] -raw_middleware!(); - -#[cfg(feature = "raw")] -anansi::setup!(); - -#[cfg(feature = "raw")] -impl_pg!(); - -#[cfg(not(feature = "raw"))] -middleware!(); - -#[derive(Clone, Debug)] -pub struct AppData { - pub pool: Pool, - #[cfg(feature = "raw")] - pub stmt: Stmt, -} - -#[cfg(feature = "raw")] -impl AppData { - pub async fn new() -> Self { - let pool = anansi::server::get_db::(app_migrations).await; - let stmt = Stmt::new(&pool).await.unwrap(); - Self {pool, stmt} - } -} - -#[cfg(not(feature = "raw"))] -impl AppData { - pub async fn new() -> Self { - let pool = anansi::server::get_db::(app_migrations).await; - Self {pool} - } -} - -impl anansi::db::AsDb for AppData { - type SqlDb = Pool; - fn as_db(&self) -> &Pool { - &self.pool - } - fn as_db_mut(&mut self) -> &mut Pool { - &mut self.pool - } -} diff --git a/frameworks/Rust/anansi/src/urls.rs b/frameworks/Rust/anansi/src/urls.rs deleted file mode 100644 index bd04cbaad43..00000000000 --- a/frameworks/Rust/anansi/src/urls.rs +++ /dev/null @@ -1,32 +0,0 @@ -use anansi::web::prelude::*; -use crate::prelude::Request; -#[cfg(not(feature = "raw"))] -use crate::hello::world::views::WorldView; - -#[cfg(not(feature = "raw"))] -pub fn routes() -> Router { - Router::new() - .route("/json", WorldView::json) - .route("/db", WorldView::db) - .route("/queries", WorldView::queries) - .route("/fortunes", WorldView::fortunes) - .route("/updates", WorldView::updates) - .route("/plaintext", WorldView::plaintext) - .route("/cached-queries", WorldView::cached_queries) -} - -#[cfg(feature = "raw")] -use crate::hello::world::raw::WorldView; - -#[cfg(feature = "raw")] -use crate::hello::middleware::Pg; - -#[cfg(feature = "raw")] -pub fn routes() -> Router { - Router::new() - .route("/db", WorldView::db) - .route("/queries", WorldView::queries) - .route("/fortunes", WorldView::raw_fortunes) - .route("/updates", WorldView::updates) - .route("/cached-queries", WorldView::cached_queries) -}