浏览代码

Add new framework - warp-rust (#5287)

* Add new framework - warp-rust

* Add api documentation link for warp
Konrad Borowski 5 年之前
父节点
当前提交
33bc849029

+ 1 - 0
.travis.yml

@@ -112,6 +112,7 @@ env:
     - 'TESTDIR="Rust/actix Rust/gotham Rust/hyper Rust/iron Rust/saphir"'
     - 'TESTDIR="Rust/may-minihttp Rust/nickel Rust/rocket"'
     - 'TESTDIR="Rust/rouille Rust/thruster Rust/tokio-minihttp"'
+    - 'TESTDIR="Rust/warp-rust"'
     - 'TESTDIR="Scala/akka-http Scala/blaze Scala/cask Scala/colossus Scala/finagle"'
     - 'TESTDIR="Scala/finatra Scala/finch Scala/http4s"'
     - 'TESTDIR="Scala/play2-scala Scala/youi"'

+ 9 - 0
frameworks/Rust/warp-rust/Cargo.toml

@@ -0,0 +1,9 @@
+[package]
+name = "warp-rust"
+version = "0.1.0"
+authors = ["Konrad Borowski <[email protected]>"]
+edition = "2018"
+
+[dependencies]
+serde = { version = "1.0.103", features = ["derive"] }
+warp = "0.1.20"

+ 19 - 0
frameworks/Rust/warp-rust/README.md

@@ -0,0 +1,19 @@
+# warp-rust Benchmarking Test
+
+warp is a composable web server framework based on hyper.
+
+* [API Documentation](https://docs.rs/warp/0.1)
+
+### Test Type Implementation Source Code
+
+* [JSON](src/main.rs)
+* [PLAINTEXT](src/main.rs)
+
+## Test URLs
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext

+ 26 - 0
frameworks/Rust/warp-rust/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "warp-rust",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "warp-rust",
+        "language": "Rust",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "Hyper",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "warp-rust",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 21 - 0
frameworks/Rust/warp-rust/src/main.rs

@@ -0,0 +1,21 @@
+use serde::Serialize;
+use warp::http::header;
+use warp::Filter;
+
+#[derive(Serialize)]
+struct Message {
+    message: &'static str,
+}
+
+fn main() {
+    let json = warp::path("json").map(|| {
+        warp::reply::json(&Message {
+            message: "Hello, world!",
+        })
+    });
+    let plaintext = warp::path("plaintext").map(|| "Hello, World!");
+    let routes = json
+        .or(plaintext)
+        .map(|reply| warp::reply::with_header(reply, header::SERVER, "warp"));
+    warp::serve(routes).run(([0, 0, 0, 0], 8080))
+}

+ 9 - 0
frameworks/Rust/warp-rust/warp-rust.dockerfile

@@ -0,0 +1,9 @@
+FROM rust:1.39
+
+WORKDIR /warp-rust
+COPY src src
+COPY Cargo.toml Cargo.toml
+
+RUN RUSTFLAGS="-C target-cpu=native" cargo build --release
+
+CMD ./target/release/warp-rust