mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
fix cd links
This commit is contained in:
parent
357983d22c
commit
4d210b32f9
@ -5,7 +5,7 @@ Basic integration of [Casbin-RS](https://github.com/casbin/casbin-rs) with [RBAC
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd security/casbin
|
cd auth/casbin
|
||||||
```
|
```
|
||||||
|
|
||||||
Modify the files in the `rbac` directory and the code in the `src` directory as required.
|
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
|
## Running Server
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd security/casbin
|
cd auth/casbin
|
||||||
cargo run (or ``cargo watch -x run``)
|
cargo run (or ``cargo watch -x run``)
|
||||||
|
|
||||||
# Started http server: 127.0.0.1:8080
|
# Started http server: 127.0.0.1:8080
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# cookie-auth
|
# cookie-auth
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd session/cookie-auth
|
cd auth/cookie-auth
|
||||||
cargo run
|
cargo run
|
||||||
# Starting http server: 127.0.0.1:8080
|
# Starting http server: 127.0.0.1:8080
|
||||||
```
|
```
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## Cookie session example
|
## Cookie session example
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd session/cookie-session
|
cd auth/cookie-session
|
||||||
cargo run
|
cargo run
|
||||||
# Starting http server: 127.0.0.1:8080
|
# Starting http server: 127.0.0.1:8080
|
||||||
```
|
```
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# redis-session
|
# redis-session
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd session/redis-sessions
|
cd auth/redis-sessions
|
||||||
cargo run
|
cargo run
|
||||||
# Starting http server: 127.0.0.1:8080
|
# Starting http server: 127.0.0.1:8080
|
||||||
```
|
```
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
## Run Server
|
## Run Server
|
||||||
```sh
|
```sh
|
||||||
cd secutiy/web-cors/backend
|
cd cors/backend
|
||||||
cargo run
|
cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
## Run Frontend
|
## Run Frontend
|
||||||
In a separate terminal, also run:
|
In a separate terminal, also run:
|
||||||
```sh
|
```sh
|
||||||
cd secutiy/web-cors/frontend
|
cd cors/frontend
|
||||||
npm install
|
npm install
|
||||||
npm run serve
|
npm run serve
|
||||||
```
|
```
|
||||||
|
@ -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
|
## Usage
|
||||||
|
|
||||||
|
@ -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).
|
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
|
## Notes
|
||||||
|
|
||||||
**Note :** You will be required to use sudo while running the binary to access port 80 and 443
|
|
||||||
|
|
||||||
|
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).
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
use std::fs::File;
|
use std::{fs::File, io::BufReader};
|
||||||
use std::io::BufReader;
|
|
||||||
|
|
||||||
use actix_web::dev::Service;
|
use actix_web::{dev::Service, get, http, App, HttpResponse, HttpServer};
|
||||||
use futures::future::FutureExt;
|
use futures::future::{self, Either, FutureExt};
|
||||||
|
|
||||||
use actix_web::{get, App, HttpServer};
|
|
||||||
use actix_web::{http, HttpResponse};
|
|
||||||
use futures::future;
|
|
||||||
use futures::future::Either;
|
|
||||||
use rustls::{Certificate, PrivateKey, ServerConfig};
|
use rustls::{Certificate, PrivateKey, ServerConfig};
|
||||||
use rustls_pemfile::{certs, pkcs8_private_keys};
|
use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||||
|
|
||||||
@ -65,8 +59,8 @@ async fn main() -> std::io::Result<()> {
|
|||||||
})
|
})
|
||||||
.service(index)
|
.service(index)
|
||||||
})
|
})
|
||||||
.bind("0.0.0.0:80")? // Port 80 to listen for http request
|
.bind("127.0.0.1:80")? // Port 80 to listen for HTTP request
|
||||||
.bind_rustls("0.0.0.0:443", config)? // Port 443 to listen for https request
|
.bind_rustls("127.0.0.1:443", config)? // Port 443 to listen for HTTPS request
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user