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:
parent
cc948594fe
commit
8186a8cfea
@ -5,16 +5,15 @@
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd examples/basics
|
||||
cd basics/basics
|
||||
cargo run
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
||||
### 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/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/favicon](http://localhost:8080/favicon)
|
||||
- [http://localhost:8080/welcome](http://localhost:8080/static/welcome.html)
|
||||
|
@ -1,12 +1,12 @@
|
||||
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
|
||||
are dumb in that they do nothing other than call an
|
||||
httpbin endpoint that returns the json that was posted to it. The intent here
|
||||
is to illustrate how to chain these steps together as futures and return
|
||||
a final result in a response.
|
||||
are dumb in that they do nothing other than call an HTTP endpoint that
|
||||
returns the json that was posted to it. The intent here is to illustrate
|
||||
how to chain these steps together as futures and return a final result
|
||||
in a response.
|
||||
|
||||
Actix-web features illustrated here include:
|
||||
Actix Web features illustrated here include:
|
||||
|
||||
1. handling json input param
|
||||
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
|
||||
|
||||
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd basics/json-validation
|
||||
cargo run
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
||||
Example query from the command line using httpie:
|
||||
```echo '{"id":"1", "name": "JohnDoe"}' | http 127.0.0.1:8080/something```
|
||||
|
@ -5,7 +5,7 @@ This example showcases a bunch of different uses of middlewares. See also the [M
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
cd middleware
|
||||
cd basics/middleware
|
||||
cargo run
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -1,3 +1,20 @@
|
||||
This example illustrates how to use nested resource registration through application-level configuration.
|
||||
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)
|
||||
|
@ -14,6 +14,7 @@ Demonstrates how to shutdown the web server in a couple of ways:
|
||||
### Running The Server
|
||||
|
||||
```bash
|
||||
cd basics/shutdown-server
|
||||
cargo run --bin shutdown-server
|
||||
|
||||
# Starting 8 workers
|
||||
|
@ -5,7 +5,7 @@
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd examples/state
|
||||
cd basics/state
|
||||
cargo run
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -9,8 +9,12 @@ Demonstrates how to serve static files. Inside the `./static` folder you will fi
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
$ cd examples/static_index
|
||||
$ cd basics/static_index
|
||||
$ 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)
|
||||
|
||||
|
@ -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:
|
||||
|
||||
```bash
|
||||
cd examples/todo
|
||||
cd basics/todo
|
||||
```
|
||||
|
||||
## Set up the database
|
||||
|
@ -1,12 +1,21 @@
|
||||
## 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
|
||||
- Follow the link ➡ register with same email and a password
|
||||
- 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.
|
||||
- [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/)
|
||||
|
||||
## Dependencies
|
||||
### Dependencies
|
||||
|
||||
On Ubuntu 19.10:
|
||||
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
### Run
|
||||
|
||||
```bash
|
||||
cd forms/multipart-async-std
|
||||
cargo run
|
||||
```
|
||||
|
||||
``` open web browser to localhost:3000 and upload file(s) ```
|
||||
|
||||
### Result
|
||||
|
@ -4,7 +4,7 @@ Receive multiple data in multipart form in JSON format and receive it as a struc
|
||||
|
||||
# usage
|
||||
```
|
||||
cd examples/multipart+s3
|
||||
cd forms/multipart-s3
|
||||
```
|
||||
1. copy .env.example .env
|
||||
2. edit .env AWS_ACCESS_KEY_ID=you_key
|
||||
@ -14,7 +14,7 @@ cd examples/multipart+s3
|
||||
|
||||
# Running Server
|
||||
```
|
||||
cd examples/multipart+s3
|
||||
cd forms/multipart-s3
|
||||
cargo run (or ``cargo watch -x run``)
|
||||
```
|
||||
http://localhost:3000
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
### Run
|
||||
|
||||
```bash
|
||||
cd forms/multipart
|
||||
cargo run
|
||||
```
|
||||
|
||||
``` open web browser to localhost:3000 and upload file(s) ```
|
||||
|
||||
### Result
|
||||
|
@ -3,6 +3,7 @@ Getting started using [Async-graphql](https://github.com/async-graphql/async-gra
|
||||
## Run
|
||||
|
||||
```bash
|
||||
cd graphql/graphql-demo
|
||||
cargo run --bin async-graphql-demo
|
||||
```
|
||||
|
||||
|
@ -17,12 +17,12 @@ Create ```.env``` file on the root directory of this project and set environment
|
||||
|
||||
```sh
|
||||
# go to the root dir
|
||||
cd juniper-advanced
|
||||
|
||||
# Run
|
||||
cd graphql/juniper-advanced
|
||||
cargo run
|
||||
```
|
||||
|
||||
## GraphQL Playground
|
||||
|
||||
<http://127.0.0.1:8080/graphiql>
|
||||
```
|
||||
http://127.0.0.1:8080/graphiql
|
||||
```
|
@ -10,7 +10,7 @@ If you want more advanced example, see also the [juniper-advanced example].
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd examples/graphql/juniper
|
||||
cd graphql/juniper
|
||||
cargo run (or ``cargo watch -x run``)
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ Json's `Getting Started` guide using json (serde-json or json-rust) for Actix we
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd examples/json
|
||||
cd json/json
|
||||
cargo run
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -9,7 +9,7 @@ representation of the error.
|
||||
## Usage
|
||||
|
||||
```shell
|
||||
cd examples/json_decode_error
|
||||
cd json/json_decode_error
|
||||
cargo run
|
||||
# Started HTTP server: 127.0.0.1:8088
|
||||
```
|
||||
|
@ -3,7 +3,8 @@ A simple demo for building a `JSONRPC over HTTP` server in [actix-web](https://g
|
||||
# Server
|
||||
|
||||
```sh
|
||||
$ cargo run
|
||||
cd json/jsonrpc
|
||||
cargo run
|
||||
# Starting server on 127.0.0.1:8080
|
||||
```
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
### Server
|
||||
|
||||
```shell
|
||||
cd other/protobuf
|
||||
# From workspace
|
||||
cargo run --bin protobuf-example
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
Example of server-sent events, aka `EventSource`, with actix web.
|
||||
|
||||
```sh
|
||||
cd other/server-sent-events
|
||||
cargo run
|
||||
```
|
||||
|
||||
@ -14,7 +15,7 @@ curl localhost:8080/broadcast/my_message
|
||||
*my_message* should appear in the browser with a timestamp.
|
||||
|
||||
## 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:
|
||||
|
||||
@ -37,4 +38,4 @@ $ node drain.js
|
||||
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.
|
@ -5,7 +5,7 @@
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd examples/udp-echo
|
||||
cd other/udp-echo
|
||||
cargo run
|
||||
# Started http server: 127.0.0.1:12345
|
||||
```
|
||||
|
@ -1,7 +1,11 @@
|
||||
## Unix domain socket example
|
||||
|
||||
```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!
|
||||
```
|
||||
|
||||
@ -10,5 +14,5 @@ according to the
|
||||
[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
|
||||
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.
|
||||
|
@ -5,7 +5,7 @@ Basic integration of [Casbin-RS](https://github.com/casbin/casbin-rs) with [RBAC
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
cd examples/casbin
|
||||
cd security/casbin
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
```sh
|
||||
cd examples/casbin
|
||||
cd security/casbin
|
||||
cargo run (or ``cargo watch -x run``)
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
### 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.
|
||||
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
|
||||
|
||||
```bash
|
||||
cd examples/openssl
|
||||
cd security/openssl
|
||||
cargo run (or ``cargo watch -x run``)
|
||||
# Started http server: 127.0.0.1:8443
|
||||
```
|
||||
|
@ -10,7 +10,7 @@ generated by [`mkcert`] that was used to create the server and client certs.
|
||||
### Server
|
||||
|
||||
```sh
|
||||
cd examples/rustls-client-cert
|
||||
cd security/rustls-client-cert
|
||||
cargo run
|
||||
```
|
||||
|
||||
|
@ -30,7 +30,7 @@ let mut keys = rsa_private_keys(key_file).unwrap(); // rsa
|
||||
|
||||
```bash
|
||||
cd security/rustls
|
||||
cargo run
|
||||
cargo run # (or ``cargo watch -x run``)
|
||||
# Started http server: 127.0.0.1:8443
|
||||
```
|
||||
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
## Run Server
|
||||
```sh
|
||||
cd web-cors/backend
|
||||
cd secutiy/web-cors/backend
|
||||
cargo run
|
||||
```
|
||||
|
||||
## Run Frontend
|
||||
In a separate terminal, also run:
|
||||
```sh
|
||||
cd web-cors/frontend
|
||||
cd secutiy/web-cors/frontend
|
||||
npm install
|
||||
npm run serve
|
||||
```
|
||||
|
@ -1,5 +1,11 @@
|
||||
# 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).
|
||||
|
||||
Login:
|
||||
|
@ -1,7 +1,7 @@
|
||||
## Cookie session example
|
||||
|
||||
```sh
|
||||
cd cookie-session
|
||||
cd session/cookie-session
|
||||
cargo run
|
||||
# Starting http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -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)
|
@ -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:
|
||||
|
||||
```bash
|
||||
cd template_engines/handlebars
|
||||
cargo run
|
||||
```
|
||||
|
||||
- http://localhost:8080
|
||||
- http://localhost:8080/Emma/documents
|
||||
- http://localhost:8080/Bob/passwords
|
||||
|
@ -7,7 +7,7 @@ Minimal example of using the template [tera](https://github.com/Keats/tera) that
|
||||
### server
|
||||
|
||||
```bash
|
||||
cd examples/template_tera
|
||||
cd template_engines/tera
|
||||
cargo run (or ``cargo watch -x run``)
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -7,7 +7,7 @@ See the documentation for the minimalist template engine [tiny_template](https:/
|
||||
### Server
|
||||
|
||||
```bash
|
||||
cd examples/template_tinytemplate
|
||||
cd template_engines/tinytemplate
|
||||
cargo run # (or ``cargo watch -x run``)
|
||||
# Started http server: 127.0.0.1:8080
|
||||
```
|
||||
|
@ -3,8 +3,8 @@
|
||||
Minimal example of using template [yarte](https://github.com/botika/yarte) that displays a form.
|
||||
|
||||
```bash
|
||||
cd template_engines/yarte
|
||||
cargo test
|
||||
|
||||
cargo run
|
||||
```
|
||||
> open `localhost:8080`
|
||||
|
@ -11,7 +11,7 @@ Differences:
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user