1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

fix broken links (#441)

Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
Co-authored-by: Altug Sahin <altugsahin@gmail.com>
Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
Altug Sahin 2021-10-06 17:28:53 -04:00 committed by GitHub
parent cc948594fe
commit 8186a8cfea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 128 additions and 47 deletions

View File

@ -5,16 +5,15 @@
### server ### server
```bash ```bash
cd examples/basics cd basics/basics
cargo run cargo run
# Started http server: 127.0.0.1:8080 # Started http server: 127.0.0.1:8080
``` ```
### web client ### web client
- [http://localhost:8080/](http://localhost:8080/static/index.html)
- [http://localhost:8080/async-body/bob](http://localhost:8080/async-body/bob) - [http://localhost:8080/async-body/bob](http://localhost:8080/async-body/bob)
- [http://localhost:8080/user/bob/](http://localhost:8080/user/bob/) text/plain download - [http://localhost:8080/user/bob/](http://localhost:8080/user/bob) text/plain download
- [http://localhost:8080/test](http://localhost:8080/test) (return status switch GET or POST or other) - [http://localhost:8080/test](http://localhost:8080/test) (return status switch GET or POST or other)
- [http://localhost:8080/favicon](http://localhost:8080/favicon) - [http://localhost:8080/favicon](http://localhost:8080/favicon)
- [http://localhost:8080/welcome](http://localhost:8080/static/welcome.html) - [http://localhost:8080/welcome](http://localhost:8080/static/welcome.html)

View File

@ -1,12 +1,12 @@
This is a contrived example intended to illustrate a few important actix-web features. This is a contrived example intended to illustrate a few important actix-web features.
*Imagine* that you have a process that involves 3 steps. The steps here *Imagine* that you have a process that involves 3 steps. The steps here
are dumb in that they do nothing other than call an are dumb in that they do nothing other than call an HTTP endpoint that
httpbin endpoint that returns the json that was posted to it. The intent here returns the json that was posted to it. The intent here is to illustrate
is to illustrate how to chain these steps together as futures and return how to chain these steps together as futures and return a final result
a final result in a response. in a response.
Actix-web features illustrated here include: Actix Web features illustrated here include:
1. handling json input param 1. handling json input param
2. validating user-submitted parameters using the 'validator' crate 2. validating user-submitted parameters using the 'validator' crate
@ -15,5 +15,13 @@ Actix-web features illustrated here include:
3. chaining futures into a single response used by an asynch endpoint 3. chaining futures into a single response used by an asynch endpoint
### server
```bash
cd basics/json-validation
cargo run
# Started http server: 127.0.0.1:8080
```
Example query from the command line using httpie: Example query from the command line using httpie:
```echo '{"id":"1", "name": "JohnDoe"}' | http 127.0.0.1:8080/something``` ```echo '{"id":"1", "name": "JohnDoe"}' | http 127.0.0.1:8080/something```

View File

@ -5,7 +5,7 @@ This example showcases a bunch of different uses of middlewares. See also the [M
## Usage ## Usage
```bash ```bash
cd middleware cd basics/middleware
cargo run cargo run
# Started http server: 127.0.0.1:8080 # Started http server: 127.0.0.1:8080
``` ```

View File

@ -1,3 +1,20 @@
This example illustrates how to use nested resource registration through application-level configuration. This example illustrates how to use nested resource registration through application-level configuration.
The endpoints do nothing. The endpoints do nothing.
## Usage
```bash
cd basics/nested-routing
cargo run
# Started http server: 127.0.0.1:8080
```
### Available Routes
- [POST /products](http://localhost:8080/products)
- [GET /products](http://localhost:8080/products)
- [GET /products/:product_id](http://localhost:8080/products/:product_id)
- [DELETE /products/:product_id](http://localhost:8080/products/:product_id)
- [GET /products/:product_id/parts](http://localhost:8080/products/:product_id/parts)
- [POST /products/:product_id/parts](http://localhost:8080/products/:product_id/parts)
- [GET /products/:product_id/parts/:part_id](http://localhost:8080/products/:product_id/parts/:part_id)

View File

@ -14,6 +14,7 @@ Demonstrates how to shutdown the web server in a couple of ways:
### Running The Server ### Running The Server
```bash ```bash
cd basics/shutdown-server
cargo run --bin shutdown-server cargo run --bin shutdown-server
# Starting 8 workers # Starting 8 workers

View File

@ -5,7 +5,7 @@
### server ### server
```bash ```bash
cd examples/state cd basics/state
cargo run cargo run
# Started http server: 127.0.0.1:8080 # Started http server: 127.0.0.1:8080
``` ```

View File

@ -9,8 +9,12 @@ Demonstrates how to serve static files. Inside the `./static` folder you will fi
## Usage ## Usage
```bash ```bash
$ cd examples/static_index $ cd basics/static_index
$ cargo run $ cargo run
``` ```
This will start the server on port 8080, it can be viewed at [http://localhost:8080](http://localhost:8080). ### Available Routes
- [GET /](http://localhost:8080/)
- [GET /images](http://localhost:8080/images)

View File

@ -14,7 +14,7 @@ A port of the [Rocket Todo example](https://github.com/SergioBenitez/Rocket/tree
All instructions assume you have changed into this folder: All instructions assume you have changed into this folder:
```bash ```bash
cd examples/todo cd basics/todo
``` ```
## Set up the database ## Set up the database

View File

@ -1,12 +1,21 @@
## Auth Web Microservice with rust using Actix-Web 1.0 ## Auth Web Microservice with rust using Actix-Web 1.0
##### Flow of the event would look like this: ### Flow of the event would look like this:
- Registers with email address ➡ Receive an 📨 with a link to verify - Registers with email address ➡ Receive an 📨 with a link to verify
- Follow the link ➡ register with same email and a password - Follow the link ➡ register with same email and a password
- Login with email and password ➡ Get verified and receive auth cookie - Login with email and password ➡ Get verified and receive auth cookie
##### Crates Used ### Available Routes
- [GET /](http://localhost:8080/)
- [POST /api/invitation](http://localhost:8080/api/invitation)
- [POST /api/invitation/:invitation_id](http://localhost:8080/api/invitation/:invitation_id)
- [GET /api/auth](http://localhost:8080/api/auth)
- [POST /api/auth](http://localhost:8080/api/auth)
- [DELETE /api/auth](http://localhost:8080/api/auth)
### Crates Used
- [actix-web](https://crates.io/crates/actix-web) // Actix web is a simple, pragmatic and extremely fast web framework for Rust. - [actix-web](https://crates.io/crates/actix-web) // Actix web is a simple, pragmatic and extremely fast web framework for Rust.
- [rust-argon2](https://crates.io/crates/rust-argon2) // crate for hashing passwords using the cryptographically-secure Argon2 hashing algorithm. - [rust-argon2](https://crates.io/crates/rust-argon2) // crate for hashing passwords using the cryptographically-secure Argon2 hashing algorithm.
@ -29,7 +38,7 @@ Read the full tutorial series on [gill.net.in](https://gill.net.in)
- [Auth Web Microservice with Rust using Actix Web v2 - Complete Tutorial](https://gill.net.in/posts/auth-microservice-rust-actix-web1.0-diesel-complete-tutorial/) - [Auth Web Microservice with Rust using Actix Web v2 - Complete Tutorial](https://gill.net.in/posts/auth-microservice-rust-actix-web1.0-diesel-complete-tutorial/)
## Dependencies ### Dependencies
On Ubuntu 19.10: On Ubuntu 19.10:

View File

@ -2,6 +2,11 @@
### Run ### Run
```bash
cd forms/multipart-async-std
cargo run
```
``` open web browser to localhost:3000 and upload file(s) ``` ``` open web browser to localhost:3000 and upload file(s) ```
### Result ### Result

View File

@ -4,7 +4,7 @@ Receive multiple data in multipart form in JSON format and receive it as a struc
# usage # usage
``` ```
cd examples/multipart+s3 cd forms/multipart-s3
``` ```
1. copy .env.example .env 1. copy .env.example .env
2. edit .env AWS_ACCESS_KEY_ID=you_key 2. edit .env AWS_ACCESS_KEY_ID=you_key
@ -14,7 +14,7 @@ cd examples/multipart+s3
# Running Server # Running Server
``` ```
cd examples/multipart+s3 cd forms/multipart-s3
cargo run (or ``cargo watch -x run``) cargo run (or ``cargo watch -x run``)
``` ```
http://localhost:3000 http://localhost:3000

View File

@ -2,6 +2,11 @@
### Run ### Run
```bash
cd forms/multipart
cargo run
```
``` open web browser to localhost:3000 and upload file(s) ``` ``` open web browser to localhost:3000 and upload file(s) ```
### Result ### Result

View File

@ -3,6 +3,7 @@ Getting started using [Async-graphql](https://github.com/async-graphql/async-gra
## Run ## Run
```bash ```bash
cd graphql/graphql-demo
cargo run --bin async-graphql-demo cargo run --bin async-graphql-demo
``` ```

View File

@ -17,12 +17,12 @@ Create ```.env``` file on the root directory of this project and set environment
```sh ```sh
# go to the root dir # go to the root dir
cd juniper-advanced cd graphql/juniper-advanced
# Run
cargo run cargo run
``` ```
## GraphQL Playground ## GraphQL Playground
<http://127.0.0.1:8080/graphiql> ```
http://127.0.0.1:8080/graphiql
```

View File

@ -10,7 +10,7 @@ If you want more advanced example, see also the [juniper-advanced example].
### server ### server
```bash ```bash
cd examples/graphql/juniper cd graphql/juniper
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
``` ```

View File

@ -7,7 +7,7 @@ Json's `Getting Started` guide using json (serde-json or json-rust) for Actix we
### server ### server
```bash ```bash
cd examples/json cd json/json
cargo run cargo run
# Started http server: 127.0.0.1:8080 # Started http server: 127.0.0.1:8080
``` ```

View File

@ -9,7 +9,7 @@ representation of the error.
## Usage ## Usage
```shell ```shell
cd examples/json_decode_error cd json/json_decode_error
cargo run cargo run
# Started HTTP server: 127.0.0.1:8088 # Started HTTP server: 127.0.0.1:8088
``` ```

View File

@ -3,7 +3,8 @@ A simple demo for building a `JSONRPC over HTTP` server in [actix-web](https://g
# Server # Server
```sh ```sh
$ cargo run cd json/jsonrpc
cargo run
# Starting server on 127.0.0.1:8080 # Starting server on 127.0.0.1:8080
``` ```

View File

@ -5,6 +5,7 @@
### Server ### Server
```shell ```shell
cd other/protobuf
# From workspace # From workspace
cargo run --bin protobuf-example cargo run --bin protobuf-example

View File

@ -2,6 +2,7 @@
Example of server-sent events, aka `EventSource`, with actix web. Example of server-sent events, aka `EventSource`, with actix web.
```sh ```sh
cd other/server-sent-events
cargo run cargo run
``` ```
@ -14,7 +15,7 @@ curl localhost:8080/broadcast/my_message
*my_message* should appear in the browser with a timestamp. *my_message* should appear in the browser with a timestamp.
## Performance ## Performance
This implementation serve thousand of clients on a 2013 macbook air without problems. This implementation serve thousands of clients on a 2013 macbook air without problems.
Run [benchmark.js](benchmark.js) to benchmark your own system: Run [benchmark.js](benchmark.js) to benchmark your own system:
@ -37,4 +38,4 @@ $ node drain.js
Connections dropped: 5957, accepting connections: false^C⏎ Connections dropped: 5957, accepting connections: false^C⏎
``` ```
_Accepting connections_ indicates wheter resources for the server have been exhausted. _Accepting connections_ indicates whether resources for the server have been exhausted.

View File

@ -5,7 +5,7 @@
### server ### server
```bash ```bash
cd examples/udp-echo cd other/udp-echo
cargo run cargo run
# Started http server: 127.0.0.1:12345 # Started http server: 127.0.0.1:12345
``` ```

View File

@ -1,7 +1,11 @@
## Unix domain socket example ## Unix domain socket example
```bash ```bash
$ curl --unix-socket /tmp/actix-uds.socket http://localhost/ cd other/unix-socket
cargo run
# in another shell
curl --unix-socket /tmp/actix-uds.socket http://localhost/
Hello world! Hello world!
``` ```
@ -10,5 +14,5 @@ according to the
[documentation](https://actix.github.io/actix-web/actix_web/struct.HttpServer.html#method.bind_uds). [documentation](https://actix.github.io/actix-web/actix_web/struct.HttpServer.html#method.bind_uds).
And it does not delete the socket file (`/tmp/actix-uds.socket`) when stopping And it does not delete the socket file (`/tmp/actix-uds.socket`) when stopping
the server so it will fail to start next time you run it unless you delete the server, so it will fail to start next time you run it unless you delete
the socket file manually. the socket file manually.

View File

@ -5,7 +5,7 @@ Basic integration of [Casbin-RS](https://github.com/casbin/casbin-rs) with [RBAC
## Usage ## Usage
```sh ```sh
cd examples/casbin cd security/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,13 +13,13 @@ Modify the files in the `rbac` directory and the code in the `src` directory as
## Running Server ## Running Server
```sh ```sh
cd examples/casbin cd security/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
``` ```
In this example, you can get the the successful result at `http://localhost:8080/success` (accessible) and the failed result at `http://localhost:8080/fail` (inaccessible, `ERR_EMPTY_RESPONSE`). In this example, you can get the successful result at `http://localhost:8080/success` (accessible) and the failed result at `http://localhost:8080/fail` (inaccessible, `ERR_EMPTY_RESPONSE`).
## Others ## Others

View File

@ -4,7 +4,7 @@
### Certificate ### Certificate
We put the self-signed certificate in this direcotry as an example We put the self-signed certificate in this directory as an example
but your browser would complain that it isn't secure. but your browser would complain that it isn't secure.
So we recommend to use [`mkcert`] to trust it. To use local CA, you should run: So we recommend to use [`mkcert`] to trust it. To use local CA, you should run:
@ -23,7 +23,7 @@ mkcert 127.0.0.1
### server ### server
```bash ```bash
cd examples/openssl cd security/openssl
cargo run (or ``cargo watch -x run``) cargo run (or ``cargo watch -x run``)
# Started http server: 127.0.0.1:8443 # Started http server: 127.0.0.1:8443
``` ```

View File

@ -10,7 +10,7 @@ generated by [`mkcert`] that was used to create the server and client certs.
### Server ### Server
```sh ```sh
cd examples/rustls-client-cert cd security/rustls-client-cert
cargo run cargo run
``` ```

View File

@ -30,7 +30,7 @@ let mut keys = rsa_private_keys(key_file).unwrap(); // rsa
```bash ```bash
cd security/rustls cd security/rustls
cargo run cargo run # (or ``cargo watch -x run``)
# Started http server: 127.0.0.1:8443 # Started http server: 127.0.0.1:8443
``` ```

View File

@ -2,14 +2,14 @@
## Run Server ## Run Server
```sh ```sh
cd web-cors/backend cd secutiy/web-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 web-cors/frontend cd secutiy/web-cors/frontend
npm install npm install
npm run serve npm run serve
``` ```

View File

@ -1,5 +1,11 @@
# cookie-auth # cookie-auth
```sh
cd session/cookie-auth
cargo run
# Starting http server: 127.0.0.1:8080
```
Testing with cookie auth with [curl](https://curl.haxx.se). Testing with cookie auth with [curl](https://curl.haxx.se).
Login: Login:

View File

@ -1,7 +1,7 @@
## Cookie session example ## Cookie session example
```sh ```sh
cd cookie-session cd session/cookie-session
cargo run cargo run
# Starting http server: 127.0.0.1:8080 # Starting http server: 127.0.0.1:8080
``` ```

View File

@ -0,0 +1,14 @@
# redis-session
```sh
cd session/redis-sessions
cargo run
# Starting http server: 127.0.0.1:8080
```
## Available Routes
- [GET /](http://localhost:8080/)
- [POST /do_something](http://localhost:8080/do_something)
- [POST /login](http://localhost:8080/login)
- [POST /logout](http://localhost:8080/logout)

View File

@ -2,6 +2,11 @@
This is an example of how to use Actix Web with the [Handlebars templating language](https://crates.io/crates/handlebars), which is currently the most popular crate that achieves this. After starting the server with `cargo run`, you may visit the following pages: This is an example of how to use Actix Web with the [Handlebars templating language](https://crates.io/crates/handlebars), which is currently the most popular crate that achieves this. After starting the server with `cargo run`, you may visit the following pages:
```bash
cd template_engines/handlebars
cargo run
```
- http://localhost:8080 - http://localhost:8080
- http://localhost:8080/Emma/documents - http://localhost:8080/Emma/documents
- http://localhost:8080/Bob/passwords - http://localhost:8080/Bob/passwords

View File

@ -7,7 +7,7 @@ Minimal example of using the template [tera](https://github.com/Keats/tera) that
### server ### server
```bash ```bash
cd examples/template_tera cd template_engines/tera
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
``` ```

View File

@ -7,7 +7,7 @@ See the documentation for the minimalist template engine [tiny_template](https:/
### Server ### Server
```bash ```bash
cd examples/template_tinytemplate cd template_engines/tinytemplate
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
``` ```

View File

@ -3,8 +3,8 @@
Minimal example of using template [yarte](https://github.com/botika/yarte) that displays a form. Minimal example of using template [yarte](https://github.com/botika/yarte) that displays a form.
```bash ```bash
cd template_engines/yarte
cargo test cargo test
cargo run cargo run
``` ```
> open `localhost:8080` > open `localhost:8080`

View File

@ -11,7 +11,7 @@ Differences:
Possible Improvements: Possible Improvements:
* Could the Chat Server Actor be simultaneously a System Service (accessible to the Chat Session via the System Registry) and also run in a seperate thread? * Could the Chat Server Actor be simultaneously a System Service (accessible to the Chat Session via the System Registry) and also run in a separate thread?
## Server ## Server