From 4d210b32f9e593f2689ac0ea2597762e0304c9d1 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 18 Feb 2022 02:18:44 +0000 Subject: [PATCH] fix cd links --- auth/casbin/README.md | 4 ++-- auth/cookie-auth/README.md | 2 +- auth/cookie-session/README.md | 2 +- auth/redis-session/README.md | 4 ++-- cors/README.md | 4 ++-- middleware/middleware-ext-mut/README.md | 4 ++-- middleware/middleware-http-to-https/README.md | 11 +++++------ middleware/middleware-http-to-https/src/main.rs | 16 +++++----------- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/auth/casbin/README.md b/auth/casbin/README.md index 81a5fa3f..2c3e24cc 100644 --- a/auth/casbin/README.md +++ b/auth/casbin/README.md @@ -5,7 +5,7 @@ Basic integration of [Casbin-RS](https://github.com/casbin/casbin-rs) with [RBAC ## Usage ```sh -cd security/casbin +cd auth/casbin ``` Modify the files in the `rbac` directory and the code in the `src` directory as required. @@ -13,7 +13,7 @@ Modify the files in the `rbac` directory and the code in the `src` directory as ## Running Server ```sh -cd security/casbin +cd auth/casbin cargo run (or ``cargo watch -x run``) # Started http server: 127.0.0.1:8080 diff --git a/auth/cookie-auth/README.md b/auth/cookie-auth/README.md index 119c138c..2ba32453 100644 --- a/auth/cookie-auth/README.md +++ b/auth/cookie-auth/README.md @@ -1,7 +1,7 @@ # cookie-auth ```sh -cd session/cookie-auth +cd auth/cookie-auth cargo run # Starting http server: 127.0.0.1:8080 ``` diff --git a/auth/cookie-session/README.md b/auth/cookie-session/README.md index 86e12a91..53ea5b66 100644 --- a/auth/cookie-session/README.md +++ b/auth/cookie-session/README.md @@ -1,7 +1,7 @@ ## Cookie session example ```sh -cd session/cookie-session +cd auth/cookie-session cargo run # Starting http server: 127.0.0.1:8080 ``` diff --git a/auth/redis-session/README.md b/auth/redis-session/README.md index 299e720e..84a4c0cc 100644 --- a/auth/redis-session/README.md +++ b/auth/redis-session/README.md @@ -1,7 +1,7 @@ # redis-session ```sh -cd session/redis-sessions +cd auth/redis-sessions cargo run # Starting http server: 127.0.0.1:8080 ``` @@ -11,4 +11,4 @@ cargo run - [GET /](http://localhost:8080/) - [POST /do_something](http://localhost:8080/do_something) - [POST /login](http://localhost:8080/login) -- [POST /logout](http://localhost:8080/logout) \ No newline at end of file +- [POST /logout](http://localhost:8080/logout) diff --git a/cors/README.md b/cors/README.md index 788ac2b3..07b5017c 100644 --- a/cors/README.md +++ b/cors/README.md @@ -2,14 +2,14 @@ ## Run Server ```sh -cd secutiy/web-cors/backend +cd cors/backend cargo run ``` ## Run Frontend In a separate terminal, also run: ```sh -cd secutiy/web-cors/frontend +cd cors/frontend npm install npm run serve ``` diff --git a/middleware/middleware-ext-mut/README.md b/middleware/middleware-ext-mut/README.md index 66bdbcfc..ea242a16 100644 --- a/middleware/middleware-ext-mut/README.md +++ b/middleware/middleware-ext-mut/README.md @@ -1,6 +1,6 @@ -# middleware examples +# Middleware: Add/Retrieve Request-Local Data -This example showcases a middleware that adds and retrieves request-local data. See also the [Middleware guide](https://actix.rs/docs/middleware/). +This example showcases a middleware that adds and retrieves request-local data. See also the [middleware guide](https://actix.rs/docs/middleware/). ## Usage diff --git a/middleware/middleware-http-to-https/README.md b/middleware/middleware-http-to-https/README.md index e3090538..7896faa9 100644 --- a/middleware/middleware-http-to-https/README.md +++ b/middleware/middleware-http-to-https/README.md @@ -1,12 +1,11 @@ -## Middleware eg - redirect any http connection to use https connection +## Middleware: Redirect Any HTTP Connection To Use HTTPS Connection This example is the next step after implementing this example : [Setup TLS via rustls](https://github.com/actix/examples/tree/master/security/rustls). -You might have already implemented TLS(using one of the ways mentioned in the example of security section), and have setup your server to listen to port 443(for https). +You might have already implemented TLS (using one of the ways mentioned in the example of security section), and have setup your server to listen to port 443 (for HTTPS). -Now, the only problem left to solve is, to listen to **http** connections as well and redirect them to use **https** +Now, the only problem left to solve is, to listen to **HTTP** connections as well and redirect them to use **HTTPS** -## Usage - -**Note :** You will be required to use sudo while running the binary to access port 80 and 443 +## Notes +Also see [`redirect_to_https`](https://docs.rs/actix-web-lab/0/actix_web_lab/middleware/fn.redirect_to_https.html) from [`actix-web-lab`](https://crates.io/crates/actix-web-lab). diff --git a/middleware/middleware-http-to-https/src/main.rs b/middleware/middleware-http-to-https/src/main.rs index fed852d5..eba165fd 100644 --- a/middleware/middleware-http-to-https/src/main.rs +++ b/middleware/middleware-http-to-https/src/main.rs @@ -1,13 +1,7 @@ -use std::fs::File; -use std::io::BufReader; +use std::{fs::File, io::BufReader}; -use actix_web::dev::Service; -use futures::future::FutureExt; - -use actix_web::{get, App, HttpServer}; -use actix_web::{http, HttpResponse}; -use futures::future; -use futures::future::Either; +use actix_web::{dev::Service, get, http, App, HttpResponse, HttpServer}; +use futures::future::{self, Either, FutureExt}; use rustls::{Certificate, PrivateKey, ServerConfig}; use rustls_pemfile::{certs, pkcs8_private_keys}; @@ -65,8 +59,8 @@ async fn main() -> std::io::Result<()> { }) .service(index) }) - .bind("0.0.0.0:80")? // Port 80 to listen for http request - .bind_rustls("0.0.0.0:443", config)? // Port 443 to listen for https request + .bind("127.0.0.1:80")? // Port 80 to listen for HTTP request + .bind_rustls("127.0.0.1:443", config)? // Port 443 to listen for HTTPS request .run() .await }