Quellcode durchsuchen

Initial Rust commit

Alexandre Leblanc vor 3 Jahren
Ursprung
Commit
b67cff22b3
7 geänderte Dateien mit 1227 neuen und 0 gelöschten Zeilen
  1. 8 0
      .idea/.gitignore
  2. 8 0
      .idea/modules.xml
  3. 11 0
      .idea/vcs-blog.iml
  4. 6 0
      .idea/vcs.xml
  5. 1152 0
      Cargo.lock
  6. 11 0
      Cargo.toml
  7. 31 0
      src/main.rs

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/vcs-blog.iml" filepath="$PROJECT_DIR$/.idea/vcs-blog.iml" />
+    </modules>
+  </component>
+</project>

+ 11 - 0
.idea/vcs-blog.iml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="CPP_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

Datei-Diff unterdrückt, da er zu groß ist
+ 1152 - 0
Cargo.lock


+ 11 - 0
Cargo.toml

@@ -0,0 +1,11 @@
+[package]
+name = "vcs-blog"
+version = "0.1.0"
+edition = "2021"
+description = "Blog engine running on version control system to store articles"
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+actix-web = "4"
+log = "0.4"
+fern = "0.6"

+ 31 - 0
src/main.rs

@@ -0,0 +1,31 @@
+use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
+use actix_web::middleware::Logger;
+use log;
+
+#[get("/")]
+async fn hello() -> impl Responder {
+    HttpResponse::Ok().body("Hello world!")
+}
+
+#[post("/echo")]
+async fn echo(req_body: String) -> impl Responder {
+    HttpResponse::Ok().body(req_body)
+}
+
+async fn manual_hello() -> impl Responder {
+    HttpResponse::Ok().body("Hey there!")
+}
+
+#[actix_web::main]
+async fn main() -> std::io::Result<()> {
+    HttpServer::new(|| {
+        App::new()
+            .wrap(Logger::default())
+            .service(hello)
+            .service(echo)
+            .route("/hey", web::get().to(manual_hello))
+    })
+        .bind(("127.0.0.1", 8080))?
+        .run()
+        .await
+}