Răsfoiți Sursa

[rust/anansi] Remove Anansi (#9653)

Anansi is currently failing and the repo hasn't seen activity in 2
years: https://github.com/saru-tora/anansi
Petrik de Heus 5 luni în urmă
părinte
comite
ca3bb9c7ec
30 a modificat fișierele cu 0 adăugiri și 749 ștergeri
  1. 0 25
      frameworks/Rust/anansi/Cargo.toml
  2. 0 36
      frameworks/Rust/anansi/README.md
  3. 0 11
      frameworks/Rust/anansi/anansi-raw.dockerfile
  4. 0 14
      frameworks/Rust/anansi/anansi.dockerfile
  5. 0 53
      frameworks/Rust/anansi/benchmark_config.json
  6. 0 18
      frameworks/Rust/anansi/settings.toml
  7. 0 94
      frameworks/Rust/anansi/src/hello/middleware.rs
  8. 0 3
      frameworks/Rust/anansi/src/hello/migrations/mod.rs
  9. 0 8
      frameworks/Rust/anansi/src/hello/mod.rs
  10. 0 48
      frameworks/Rust/anansi/src/hello/records.rs
  11. 0 5
      frameworks/Rust/anansi/src/hello/world/mod.rs
  12. 0 110
      frameworks/Rust/anansi/src/hello/world/raw.rs
  13. 0 9
      frameworks/Rust/anansi/src/hello/world/templates/.parsed/base.in
  14. 0 1
      frameworks/Rust/anansi/src/hello/world/templates/.parsed/base_args.in
  15. 0 6
      frameworks/Rust/anansi/src/hello/world/templates/.parsed/fortunes.in
  16. 0 1
      frameworks/Rust/anansi/src/hello/world/templates/.parsed/index.in
  17. 0 4
      frameworks/Rust/anansi/src/hello/world/templates/.parsed/raw_fortunes.in
  18. 0 9
      frameworks/Rust/anansi/src/hello/world/templates/base.rs.html
  19. 0 10
      frameworks/Rust/anansi/src/hello/world/templates/fortunes.rs.html
  20. 0 10
      frameworks/Rust/anansi/src/hello/world/templates/raw_fortunes.rs.html
  21. 0 16
      frameworks/Rust/anansi/src/hello/world/util.rs
  22. 0 90
      frameworks/Rust/anansi/src/hello/world/views.rs
  23. 0 11
      frameworks/Rust/anansi/src/http_errors/500.html
  24. 0 1
      frameworks/Rust/anansi/src/http_errors/mod.rs
  25. 0 11
      frameworks/Rust/anansi/src/http_errors/templates/.parsed/not_found.in
  26. 0 11
      frameworks/Rust/anansi/src/http_errors/templates/not_found.rs.html
  27. 0 12
      frameworks/Rust/anansi/src/http_errors/views.rs
  28. 0 28
      frameworks/Rust/anansi/src/main.rs
  29. 0 62
      frameworks/Rust/anansi/src/project.rs
  30. 0 32
      frameworks/Rust/anansi/src/urls.rs

+ 0 - 25
frameworks/Rust/anansi/Cargo.toml

@@ -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

+ 0 - 36
frameworks/Rust/anansi/README.md

@@ -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

+ 0 - 11
frameworks/Rust/anansi/anansi-raw.dockerfile

@@ -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

+ 0 - 14
frameworks/Rust/anansi/anansi.dockerfile

@@ -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

+ 0 - 53
frameworks/Rust/anansi/benchmark_config.json

@@ -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"
-      }
-    }
-  ]
-}

+ 0 - 18
frameworks/Rust/anansi/settings.toml

@@ -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"

+ 0 - 94
frameworks/Rust/anansi/src/hello/middleware.rs

@@ -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<anansi::db::postgres::PgDbRow> {
-                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<anansi::db::postgres::PgDbRowVec> {
-                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<State>);
-
-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<Self> {
-        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<PgStatement>,
-    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<PgDbRow>;
-    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<PgDbRowVec>;
-}

+ 0 - 3
frameworks/Rust/anansi/src/hello/migrations/mod.rs

@@ -1,3 +0,0 @@
-use anansi::migrations::prelude::*;
-
-local_migrations! {}

+ 0 - 8
frameworks/Rust/anansi/src/hello/mod.rs

@@ -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;

+ 0 - 48
frameworks/Rust/anansi/src/hello/records.rs

@@ -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<R: BaseRequest> Relate<R> 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<R: BaseRequest> Relate<R> for Fortune {
-    async fn on_save(&self, _req: &mut R) -> Result<()> {
-        unimplemented!();
-    }
-    async fn on_delete(&self, _req: &R) -> Result<()> {
-        unimplemented!();
-    }
-}

+ 0 - 5
frameworks/Rust/anansi/src/hello/world/mod.rs

@@ -1,5 +0,0 @@
-#[cfg(not(feature = "raw"))]
-pub mod views;
-#[cfg(feature = "raw")]
-pub mod raw;
-pub mod util;

+ 0 - 110
frameworks/Rust/anansi/src/hello/world/raw.rs

@@ -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<R: Request>(_req: &mut R) -> Result<Response> {}
-
-#[viewer]
-impl<R: Request + Pg> WorldView<R> {
-    async fn one_world(req: &R) -> Result<World> {
-        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<Vec<World>> {
-        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<Response> {
-        let world = Self::one_world(req).await?;
-        Response::json(&world)
-    }
-    #[check(Site::is_visitor)]
-    pub async fn queries(req: &mut R) -> Result<Response> {
-        let worlds = Self::get_worlds(req).await?;
-        Response::json(&worlds)
-    }
-    #[view(Site::is_visitor)]
-    pub async fn raw_fortunes(req: &mut R) -> Result<Response> {
-        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<Response> {
-        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<Response> {
-        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)
-    }
-}

+ 0 - 9
frameworks/Rust/anansi/src/hello/world/templates/.parsed/base.in

@@ -1,9 +0,0 @@
-{let mut _c = String::new();_c.push_str("<!DOCTYPE html>
-<html lang=\"en\">
-        <head>
-                <title>");_c.push_str(&_base_args._title);_c.push_str("</title>
-        </head>
-        <body>
-                ");_c.push_str(&_base_args._content);_c.push_str("
-        </body>
-</html>");_c.into_bytes()}

+ 0 - 1
frameworks/Rust/anansi/src/hello/world/templates/.parsed/base_args.in

@@ -1 +0,0 @@
-pub struct Args {pub _title: String,pub _content: String,}impl anansi::cache::Cacheable for Args {fn to_bytes(&self) -> Vec<u8> {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<u8>) -> anansi::web::Result<Self> {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(), }}}

+ 0 - 6
frameworks/Rust/anansi/src/hello/world/templates/.parsed/fortunes.in

@@ -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("    <table>
-    <tr><th>id</th><th>message</th></tr>
-    ");for fortune in fortunes {_c.push_str("
-        <tr><td>");_c.push_str(&anansi::web::html_escape(&format!("{}", fortune.pk())));_c.push_str("</td><td>");_c.push_str(&anansi::web::html_escape(&format!("{}", fortune.message)));_c.push_str("</td></tr>
-    ");}_c.push_str("
-    </table>"); _c};_args}

+ 0 - 1
frameworks/Rust/anansi/src/hello/world/templates/.parsed/index.in

@@ -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("	<h1>");_c.push_str(&anansi::web::html_escape(&format!("{}", title)));_c.push_str("</h1>"); _c};_args}

+ 0 - 4
frameworks/Rust/anansi/src/hello/world/templates/.parsed/raw_fortunes.in

@@ -1,4 +0,0 @@
-{_args._content = {let mut _c = String::new();_c.push_str("<table><tr><th>id</th><th>message</th></tr>");
-for fortune in fortunes {_c.push_str(&format!("<tr><td>{}</td><td>", fortune.id));anansi::web::html_escape2(&mut _c, fortune.message);_c.push_str("</td></tr>");}
-_c.push_str("</table>"); _c};
-_args._title = {let mut _c = String::new();_c.push_str(&format!("{}", title)); _c};_args}

+ 0 - 9
frameworks/Rust/anansi/src/hello/world/templates/base.rs.html

@@ -1,9 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-        <head>
-                <title>@block title</title>
-        </head>
-        <body>
-                @block content
-        </body>
-</html>

+ 0 - 10
frameworks/Rust/anansi/src/hello/world/templates/fortunes.rs.html

@@ -1,10 +0,0 @@
-@block title {@title}
-
-@block content {
-    <table>
-    <tr><th>id</th><th>message</th></tr>
-    @for fortune in fortunes {
-        <tr><td>@fortune.pk()</td><td>@fortune.message</td></tr>
-    }
-    </table>
-}

+ 0 - 10
frameworks/Rust/anansi/src/hello/world/templates/raw_fortunes.rs.html

@@ -1,10 +0,0 @@
-@block title {@unescape title}
-
-@block content {
-    <table>
-    <tr><th>id</th><th>message</th></tr>
-    @for fortune in fortunes {
-        <tr><td>@unescape fortune.id</td><td>@fortune.message</td></tr>
-    }
-    </table>
-}

+ 0 - 16
frameworks/Rust/anansi/src/hello/world/util.rs

@@ -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
-}

+ 0 - 90
frameworks/Rust/anansi/src/hello/world/views.rs

@@ -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<R: Request>(_req: &mut R) -> Result<Response> {}
-
-#[viewer]
-impl<R: Request> WorldView<R> {
-    #[check(Site::is_visitor)]
-    pub async fn json(req: &mut R) -> Result<Response> {
-        let message = Message {message: "Hello, World!"};
-        Response::json(&message)
-    }
-    async fn get_world(req: &R) -> Result<World> {
-        World::find(random_int()).get(req).await
-    }
-    async fn get_worlds(req: &R) -> Result<Vec<World>> {
-        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<Response> {
-        let world = Self::get_world(req).await?;
-        Response::json(&world)
-    }
-    #[check(Site::is_visitor)]
-    pub async fn queries(req: &mut R) -> Result<Response> {
-        let worlds = Self::get_worlds(req).await?;
-        Response::json(&worlds)
-    }
-    #[view(Site::is_visitor)]
-    pub async fn fortunes(req: &mut R) -> Result<Response> {
-        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<Response> {
-        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<Response> {
-        Ok(Response::text("Hello, World!".to_string()))
-    }
-    #[check(Site::is_visitor)]
-    pub async fn cached_queries(req: &mut R) -> Result<Response> {
-        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)
-    }
-}

+ 0 - 11
frameworks/Rust/anansi/src/http_errors/500.html

@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8">
-		<title>500 Internal Server Error</title>
-	</head>
-	<body>
-		<h1>Internal Server Error</h1>
-		<p>Sorry, something went wrong.</p>
-	</body>
-</html>

+ 0 - 1
frameworks/Rust/anansi/src/http_errors/mod.rs

@@ -1 +0,0 @@
-pub mod views;

+ 0 - 11
frameworks/Rust/anansi/src/http_errors/templates/.parsed/not_found.in

@@ -1,11 +0,0 @@
-{let mut _c = String::new();_c.push_str("<!DOCTYPE html>
-<html lang=\"en\">
-	<head>
-		<meta charset=\"utf-8\">
-		<title>Not Found</title>
-	</head>
-	<body>
-		<h1>404</h1>
-		<p>Page not found.</p>
-	</body>
-</html>");_c.into_bytes()}

+ 0 - 11
frameworks/Rust/anansi/src/http_errors/templates/not_found.rs.html

@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8">
-		<title>Not Found</title>
-	</head>
-	<body>
-		<h1>404</h1>
-		<p>Page not found.</p>
-	</body>
-</html>

+ 0 - 12
frameworks/Rust/anansi/src/http_errors/views.rs

@@ -1,12 +0,0 @@
-use anansi::{check, viewer, render};
-use anansi::web::{Result, Response};
-use anansi::site::Site;
-use crate::project::Request;
-
-#[viewer]
-impl<R: Request> ErrorView<R> {
-    #[check(Site::is_visitor)]
-    pub async fn not_found(_req: &mut R) -> Result<Response> {
-        render!("not_found")
-    }
-}

+ 0 - 28
frameworks/Rust/anansi/src/main.rs

@@ -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");
-});

+ 0 - 62
frameworks/Rust/anansi/src/project.rs

@@ -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::<AppData>(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::<AppData>(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
-    }
-}

+ 0 - 32
frameworks/Rust/anansi/src/urls.rs

@@ -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<R: Request>() -> Router<R> {
-    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<R: Request + Pg>() -> Router<R> {
-    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)
-}