1
0
mirror of https://github.com/actix/actix-website synced 2024-11-27 10:02:57 +01:00

Add extension recommendations, fix linting warnings, improve accessibility (#378)

* chore: add VS Code extension recommendations

* Update image URLs in README and documentation files

* chore: disable no-inline-html rule

* chore: use standard md/mdx syntax, and use .jsx for react components

* chore: fix email links in Code of Conduct

The commit message suggests fixing the email links in the Code of Conduct file to use the correct `mailto:` syntax.

* chore: update actix-web error helper links

Update the links to the `actix-web` error helper traits in the `databases.md` and `errors.md` files to use the correct URLs.

* chore: restore unused actix-web error helper links

* Update src/pages/community/coc.md

Co-authored-by: Rob Ede <robjtede@icloud.com>

* Update docs/getting-started.md

Co-authored-by: Rob Ede <robjtede@icloud.com>

---------

Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
Hichem Fantar 2024-05-27 21:55:31 +01:00 committed by GitHub
parent a04f1bb6ff
commit 2aacdf2f70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 60 additions and 53 deletions

7
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"davidanson.vscode-markdownlint",
"unifiedjs.vscode-mdx"
]
}

14
.vscode/settings.json vendored
View File

@ -1,9 +1,9 @@
{ {
"cSpell.words": [ "cSpell.words": ["actix", "deserialization", "rustls", "serde", "struct"],
"actix", "markdownlint.config": {
"deserialization", "no-inline-html": false,
"rustls", "link-image-reference-definitions": false,
"serde", "commands-show-output": false,
"struct" "fenced-code-language": false
] }
} }

View File

@ -11,7 +11,7 @@ npm install # or yarn install
npm start # or yarn start npm start # or yarn start
``` ```
Then visit http://localhost:3000. Then visit <http://localhost:3000>.
## Updating diagrams ## Updating diagrams
@ -37,4 +37,3 @@ This site is licensed under either of
[docusaurus]: https://docusaurus.io/ [docusaurus]: https://docusaurus.io/
[mermaid_cli]: https://github.com/mermaidjs/mermaid.cli [mermaid_cli]: https://github.com/mermaidjs/mermaid.cli

View File

@ -2,7 +2,7 @@
title: Application title: Application
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Writing an Application # Writing an Application

View File

@ -10,23 +10,23 @@ Once connection accepted Application level protocol processing happens in a prot
Please note, below diagrams are outlining happy-path scenarios only. Please note, below diagrams are outlining happy-path scenarios only.
![](/img/diagrams/connection_overview.svg) ![Connection Overview](/img/diagrams/connection_overview.svg)
## Accept loop in more detail ## Accept loop in more detail
![](/img/diagrams/connection_accept.svg) ![Connection Accept](/img/diagrams/connection_accept.svg "Connection Accept")
Most of code implementation resides in [`actix-server`][server] crate for struct [`Accept`][accept]. Most of code implementation resides in [`actix-server`][server] crate for struct [`Accept`][accept].
## Worker loop in more detail ## Worker loop in more detail
![](/img/diagrams/connection_worker.svg) ![Connection Worker](/img/diagrams/connection_worker.svg "Connection Worker")
Most of code implementation resides in [`actix-server`][server] crate for struct [`Worker`][worker]. Most of code implementation resides in [`actix-server`][server] crate for struct [`Worker`][worker].
## Request loop roughly ## Request loop roughly
![](/img/diagrams/connection_request.svg) ![Connection Request](/img/diagrams/connection_request.svg "Connection Request")
Most of code implementation for request loop resides in [`actix-web`][web] and [`actix-http`][http] crates. Most of code implementation for request loop resides in [`actix-web`][web] and [`actix-http`][http] crates.

View File

@ -2,15 +2,15 @@
title: Databases title: Databases
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Async Options # Async Options
We have several example projects showing use of async database adapters: We have several example projects showing use of async database adapters:
- Postgres: https://github.com/actix/examples/tree/master/databases/postgres - [Postgres](https://github.com/actix/examples/tree/master/databases/postgres)
- SQLite: https://github.com/actix/examples/tree/master/databases/sqlite - [SQLite](https://github.com/actix/examples/tree/master/databases/sqlite)
- MongoDB: https://github.com/actix/examples/tree/master/databases/mongodb - [MongoDB](https://github.com/actix/examples/tree/master/databases/mongodb)
# Diesel # Diesel
@ -30,7 +30,7 @@ This example also maps the error to an `HttpResponse` before using the `?` opera
<CodeBlock example="databases" file="main.rs" section="index" /> <CodeBlock example="databases" file="main.rs" section="index" />
That's it! See the full example here: https://github.com/actix/examples/tree/master/databases/diesel That's it! See the full example [here](https://github.com/actix/examples/tree/master/databases/diesel).
[web-block]: https://docs.rs/actix-web/4/actix_web/web/fn.block.html [web-block]: https://docs.rs/actix-web/4/actix_web/web/fn.block.html
[response-error]: https://docs.rs/actix-web/4/actix_web/trait.ResponseError.html [response-error]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html

View File

@ -2,7 +2,7 @@
title: Errors title: Errors
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Errors # Errors
@ -62,7 +62,7 @@ See the [API documentation for actix-web's `error` module][actixerror] for a ful
Actix logs all errors at the `WARN` log level. If an application's log level is set to `DEBUG` and `RUST_BACKTRACE` is enabled, the backtrace is also logged. These are configurable with environmental variables: Actix logs all errors at the `WARN` log level. If an application's log level is set to `DEBUG` and `RUST_BACKTRACE` is enabled, the backtrace is also logged. These are configurable with environmental variables:
``` ```sh
>> RUST_BACKTRACE=1 RUST_LOG=actix_web=debug cargo run >> RUST_BACKTRACE=1 RUST_LOG=actix_web=debug cargo run
``` ```
@ -99,7 +99,7 @@ log = "0.4"
<CodeBlock example="errors" file="logging.rs" section="logging" /> <CodeBlock example="errors" file="logging.rs" section="logging" />
[actixerror]: https://docs.rs/actix-web/4/actix_web/error/struct.Error.html [actixerror]: https://docs.rs/actix-web/4/actix_web/error/struct.Error.html
[errorhelpers]: https://docs.rs/actix-web/4/actix_web/trait.ResponseError.html [errorhelpers]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html
[derive_more]: https://crates.io/crates/derive_more [derive_more]: https://crates.io/crates/derive_more
[responseerror]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html [responseerror]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html
[responseerrorimpls]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html#foreign-impls [responseerrorimpls]: https://docs.rs/actix-web/4/actix_web/error/trait.ResponseError.html#foreign-impls

View File

@ -2,7 +2,7 @@
title: Extractors title: Extractors
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Type-safe information extraction # Type-safe information extraction

View File

@ -2,7 +2,7 @@
title: Getting Started title: Getting Started
--- ---
import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from "@site/src/components/code_block.js"; import { rustVersion, actixWebMajorVersion } from "@site/vars"; import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from "@site/src/components/code_block"; import { rustVersion, actixWebMajorVersion } from "@site/vars";
## Installing Rust ## Installing Rust

View File

@ -2,7 +2,7 @@
title: Handlers title: Handlers
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Request Handlers # Request Handlers

View File

@ -2,7 +2,7 @@
title: HTTP/2 title: HTTP/2
--- ---
import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block.js'; import { actixWebMajorVersion } from "@site/vars"; import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block'; import { actixWebMajorVersion } from "@site/vars";
`actix-web` automatically upgrades connections to _HTTP/2_ if possible. `actix-web` automatically upgrades connections to _HTTP/2_ if possible.

View File

@ -19,4 +19,4 @@ async fn main() -> std::io::Result<()> {
} }
``` ```
![](/img/diagrams/http_server.svg) ![HTTP Server Diagram](/img/diagrams/http_server.svg)

View File

@ -2,7 +2,7 @@
title: Middleware title: Middleware
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Middleware # Middleware
@ -49,7 +49,7 @@ Create `Logger` middleware with the specified `format`. Default `Logger` can be
The following is an example of the default logging format: The following is an example of the default logging format:
``` ```log
INFO:actix_web::middleware::logger: 127.0.0.1:59934 [02/Dec/2017:00:21:43 -0800] "GET / HTTP/1.1" 302 0 "-" "curl/7.54.0" 0.000397 INFO:actix_web::middleware::logger: 127.0.0.1:59934 [02/Dec/2017:00:21:43 -0800] "GET / HTTP/1.1" 302 0 "-" "curl/7.54.0" 0.000397
INFO:actix_web::middleware::logger: 127.0.0.1:59947 [02/Dec/2017:00:22:40 -0800] "GET /index.html HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0" 0.000646 INFO:actix_web::middleware::logger: 127.0.0.1:59947 [02/Dec/2017:00:22:40 -0800] "GET /index.html HTTP/1.1" 200 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0" 0.000646
``` ```

View File

@ -2,7 +2,7 @@
title: Requests title: Requests
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# JSON Request # JSON Request

View File

@ -2,7 +2,7 @@
title: Responses title: Responses
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Response # Response

View File

@ -2,7 +2,7 @@
title: Server title: Server
--- ---
import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block.js'; import { actixWebMajorVersion } from "@site/vars"; import RenderCodeBlock from '@theme/CodeBlock'; import CodeBlock from '@site/src/components/code_block'; import { actixWebMajorVersion } from "@site/vars";
# The HTTP Server # The HTTP Server
@ -70,8 +70,7 @@ openssl = { version = "0.10" }
To create the key.pem and cert.pem use the command. **Fill in your own subject** To create the key.pem and cert.pem use the command. **Fill in your own subject**
```bash ```bash
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem \ $ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -sha256 -subj "/C=CN/ST=Fujian/L=Xiamen/O=TVlinux/OU=Org/CN=muro.lxd"
-days 365 -sha256 -subj "/C=CN/ST=Fujian/L=Xiamen/O=TVlinux/OU=Org/CN=muro.lxd"
``` ```
To remove the password, then copy nopass.pem to key.pem To remove the password, then copy nopass.pem to key.pem

View File

@ -2,11 +2,11 @@
title: Hosting on Shuttle title: Hosting on Shuttle
--- ---
import CodeBlock from '@site/src/components/code_block.js'; import CodeBlock from '@site/src/components/code_block';
# Hosting on Shuttle # Hosting on Shuttle
<img width="300" src="https://raw.githubusercontent.com/shuttle-hq/shuttle/master/assets/logo-rectangle-transparent.png"/> <img width="300" src="https://raw.githubusercontent.com/shuttle-hq/shuttle/master/assets/logo-rectangle-transparent.png" alt="Shuttle Logo"/>
> [**Shuttle**](https://www.shuttle.rs) is a Rust-native cloud development platform that lets you deploy your Rust apps for free. > [**Shuttle**](https://www.shuttle.rs) is a Rust-native cloud development platform that lets you deploy your Rust apps for free.

View File

@ -2,7 +2,7 @@
title: Static Files title: Static Files
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Individual file # Individual file

View File

@ -2,7 +2,7 @@
title: Testing title: Testing
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Testing # Testing

View File

@ -2,7 +2,7 @@
title: URL Dispatch title: URL Dispatch
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# URL Dispatch # URL Dispatch
@ -12,7 +12,7 @@ URL dispatch provides a simple way for mapping URLs to handler code using a simp
## Resource configuration ## Resource configuration
Resource configuration is the act of adding a new resources to an application. A resource has a name, which acts as an identifier to be used for URL generation. The name also allows developers to add routes to existing resources. A resource also has a pattern, meant to match against the _PATH_ portion of a _URL_ (the portion following the scheme and port, e.g. _/foo/bar_ in the _URL_ _http://localhost:8080/foo/bar?q=value_). It does not match against the _QUERY_ portion (the portion that follows _?_, e.g. _q=value_ in _http://localhost:8080/foo/bar?q=value_). Resource configuration is the act of adding a new resources to an application. A resource has a name, which acts as an identifier to be used for URL generation. The name also allows developers to add routes to existing resources. A resource also has a pattern, meant to match against the _PATH_ portion of a _URL_ (the portion following the scheme and port, e.g. _/foo/bar_ in the _URL_ _`http://localhost:8080/foo/bar?q=value`_). It does not match against the _QUERY_ portion (the portion that follows _?_, e.g. _q=value_ in _`http://localhost:8080/foo/bar?q=value`_).
The [_App::route()_][approute] method provides simple way of registering routes. This method adds a single route to application routing table. This method accepts a _path pattern_, _HTTP method_ and a handler function. `route()` method could be called multiple times for the same path, in that case, multiple routes register for the same resource path. The [_App::route()_][approute] method provides simple way of registering routes. This method adds a single route to application routing table. This method accepts a _path pattern_, _HTTP method_ and a handler function. `route()` method could be called multiple times for the same path, in that case, multiple routes register for the same resource path.
@ -206,7 +206,7 @@ Use the [_HttpRequest.url_for()_][urlfor] method to generate URLs based on resou
<CodeBlock example="url-dispatch" file="urls.rs" section="url" /> <CodeBlock example="url-dispatch" file="urls.rs" section="url" />
This would return something like the string `http://example.com/test/1/2/3` (at least if the current protocol and hostname implied http://example.com). `url_for()` method returns [_Url object_][urlobj] so you can modify this url (add query parameters, anchor, etc). `url_for()` could be called only for _named_ resources otherwise error get returned. This would return something like the string `http://example.com/test/1/2/3` (at least if the current protocol and hostname implied `http://example.com`). `url_for()` method returns [_Url object_][urlobj] so you can modify this url (add query parameters, anchor, etc). `url_for()` could be called only for _named_ resources otherwise error get returned.
## External resources ## External resources

View File

@ -2,7 +2,7 @@
title: Websockets title: Websockets
--- ---
import CodeBlock from "@site/src/components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
# Websockets # Websockets

View File

@ -3,11 +3,13 @@ title: Contributor Covenant Code of Conduct
description: The code of conduct description: The code of conduct
--- ---
# Our Pledge # Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
# Our Standards ## Our Standards
Examples of behavior that contributes to creating a positive environment include: Examples of behavior that contributes to creating a positive environment include:
@ -25,28 +27,28 @@ Examples of unacceptable behavior by participants include:
- Publishing others' private information, such as a physical or electronic address, without explicit permission - Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting - Other conduct which could reasonably be considered inappropriate in a professional setting
# Our Responsibilities ## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
# Scope ## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
# Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at robjtede@icloud.com ([@robjtede]) or jtitor@2k36.org ([@JohnTitor]). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [robjtede@icloud.com](mailto:robjtede@icloud.com) ([@robjtede]) or [jtitor@2k36.org](mailto:jtitor@2k36.org) ([@JohnTitor]). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
[@robjtede]: https://github.com/robjtede [@robjtede]: https://github.com/robjtede
[@JohnTitor]: https://github.com/JohnTitor [@JohnTitor]: https://github.com/JohnTitor
# Attribution ## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] This Code of Conduct is adapted from the [Contributor Covenant][homepage], [Version 1.4][version].
[homepage]: http://contributor-covenant.org [homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/ [version]: http://contributor-covenant.org/version/1/4/

View File

@ -2,7 +2,7 @@ import clsx from "clsx";
import React from "react"; import React from "react";
import Link from "@docusaurus/Link"; import Link from "@docusaurus/Link";
import Layout from "@theme/Layout"; import Layout from "@theme/Layout";
import CodeBlock from "../components/code_block.js"; import CodeBlock from "@site/src/components/code_block";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import useBaseUrl from "@docusaurus/useBaseUrl"; import useBaseUrl from "@docusaurus/useBaseUrl";
import styles from "./styles.module.scss"; import styles from "./styles.module.scss";