diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index bf6d4266f5..a2c1f9fd7f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,8 +11,12 @@ on: jobs: check: - # Run `cargo check` first to ensure that the pushed code at least compiles. runs-on: ubuntu-latest + strategy: + matrix: + pwd: + - . + - examples steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 @@ -23,15 +27,13 @@ jobs: components: clippy, rustfmt - uses: Swatinem/rust-cache@v1 - name: Check - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all --all-targets --all-features + working-directory: ${{ matrix.pwd }} + run: | + cargo clippy --all --all-targets --all-features - name: rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + working-directory: ${{ matrix.pwd }} + run: | + cargo fmt --all -- --check check-docs: runs-on: ubuntu-latest @@ -106,6 +108,7 @@ jobs: args: > -p axum -p axum-extra + -p axum-core --all-features --all-targets # the compiler errors are different on 1.54 which makes # the trybuild tests in axum-macros fail, so just run the doc diff --git a/.gitignore b/.gitignore index ad2f0ff108..7dace2a393 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target +/examples/target Cargo.lock -.DS_Store \ No newline at end of file +.DS_Store diff --git a/Cargo.toml b/Cargo.toml index 5120e29ccd..51b1cc394e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,4 @@ members = [ "axum-core", "axum-extra", "axum-macros", - "examples/*", ] diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 0000000000..4f10fc347e --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["*"] +exclude = ["target"] diff --git a/examples/async-graphql/src/main.rs b/examples/async-graphql/src/main.rs index 9bc47a03de..7d03d3b95f 100644 --- a/examples/async-graphql/src/main.rs +++ b/examples/async-graphql/src/main.rs @@ -3,7 +3,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-async-graphql +//! cd examples && cargo run -p example-async-graphql //! ``` mod starwars; diff --git a/examples/chat/src/main.rs b/examples/chat/src/main.rs index 6ad186698a..5107323ea8 100644 --- a/examples/chat/src/main.rs +++ b/examples/chat/src/main.rs @@ -3,7 +3,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-chat +//! cd examples && cargo run -p example-chat //! ``` use axum::{ diff --git a/examples/consume-body-in-extractor-or-middleware/src/main.rs b/examples/consume-body-in-extractor-or-middleware/src/main.rs index 9b4e42a303..1fdd90221a 100644 --- a/examples/consume-body-in-extractor-or-middleware/src/main.rs +++ b/examples/consume-body-in-extractor-or-middleware/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-consume-body-in-extractor-or-middleware +//! cd examples && cargo run -p example-consume-body-in-extractor-or-middleware //! ``` use axum::{ diff --git a/examples/cors/src/main.rs b/examples/cors/src/main.rs index 939b49d448..e74258dfc3 100644 --- a/examples/cors/src/main.rs +++ b/examples/cors/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-cors +//! cd examples && cargo run -p example-cors //! ``` use axum::{ diff --git a/examples/customize-extractor-error/src/main.rs b/examples/customize-extractor-error/src/main.rs index fcfd1726f1..bc0973b4c6 100644 --- a/examples/customize-extractor-error/src/main.rs +++ b/examples/customize-extractor-error/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-customize-extractor-error +//! cd examples && cargo run -p example-customize-extractor-error //! ``` use axum::{ diff --git a/examples/customize-path-rejection/src/main.rs b/examples/customize-path-rejection/src/main.rs index f78101f001..4e26894959 100644 --- a/examples/customize-path-rejection/src/main.rs +++ b/examples/customize-path-rejection/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-customize-path-rejection +//! cd examples && cargo run -p example-customize-path-rejection //! ``` use axum::{ diff --git a/examples/error-handling-and-dependency-injection/src/main.rs b/examples/error-handling-and-dependency-injection/src/main.rs index b58c6432e9..d92b43bf49 100644 --- a/examples/error-handling-and-dependency-injection/src/main.rs +++ b/examples/error-handling-and-dependency-injection/src/main.rs @@ -4,7 +4,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-error-handling-and-dependency-injection +//! cd examples && cargo run -p example-error-handling-and-dependency-injection //! ``` use axum::{ diff --git a/examples/form/src/main.rs b/examples/form/src/main.rs index 6b11d0e644..7605bafffb 100644 --- a/examples/form/src/main.rs +++ b/examples/form/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-form +//! cd examples && cargo run -p example-form //! ``` use axum::{extract::Form, response::Html, routing::get, Router}; diff --git a/examples/global-404-handler/src/main.rs b/examples/global-404-handler/src/main.rs index 896f743f19..385a0e21e3 100644 --- a/examples/global-404-handler/src/main.rs +++ b/examples/global-404-handler/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-global-404-handler +//! cd examples && cargo run -p example-global-404-handler //! ``` use axum::{ diff --git a/examples/graceful-shutdown/src/main.rs b/examples/graceful-shutdown/src/main.rs index 3704889a85..f4a0fc29ed 100644 --- a/examples/graceful-shutdown/src/main.rs +++ b/examples/graceful-shutdown/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-graceful-shutdown +//! cd examples && cargo run -p example-graceful-shutdown //! kill or ctrl-c //! ``` diff --git a/examples/hello-world/src/main.rs b/examples/hello-world/src/main.rs index 466cacebcc..ed115f6b2f 100644 --- a/examples/hello-world/src/main.rs +++ b/examples/hello-world/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-hello-world +//! cd examples && cargo run -p example-hello-world //! ``` use axum::{response::Html, routing::get, Router}; diff --git a/examples/key-value-store/src/main.rs b/examples/key-value-store/src/main.rs index 649e25c22e..0ad5b7f670 100644 --- a/examples/key-value-store/src/main.rs +++ b/examples/key-value-store/src/main.rs @@ -3,7 +3,7 @@ //! Run with: //! //! ```not_rust -//! cargo run -p example-key-value-store +//! cd examples && cargo run -p example-key-value-store //! ``` use axum::{ diff --git a/examples/low-level-rustls/src/main.rs b/examples/low-level-rustls/src/main.rs index 103cbcfcc0..1a0778740f 100644 --- a/examples/low-level-rustls/src/main.rs +++ b/examples/low-level-rustls/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-low-level-rustls +//! cd examples && cargo run -p example-low-level-rustls //! ``` use axum::{extract::ConnectInfo, routing::get, Router}; diff --git a/examples/multipart-form/src/main.rs b/examples/multipart-form/src/main.rs index 87e70cc11c..7c6c141088 100644 --- a/examples/multipart-form/src/main.rs +++ b/examples/multipart-form/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-multipart-form +//! cd examples && cargo run -p example-multipart-form //! ``` use axum::{ diff --git a/examples/print-request-response/src/main.rs b/examples/print-request-response/src/main.rs index 3357579f11..59c609dd83 100644 --- a/examples/print-request-response/src/main.rs +++ b/examples/print-request-response/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-print-request-response +//! cd examples && cargo run -p example-print-request-response //! ``` use axum::{ diff --git a/examples/prometheus-metrics/src/main.rs b/examples/prometheus-metrics/src/main.rs index fc58882f7f..1152b3c795 100644 --- a/examples/prometheus-metrics/src/main.rs +++ b/examples/prometheus-metrics/src/main.rs @@ -4,7 +4,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-prometheus-metrics +//! cd examples && cargo run -p example-prometheus-metrics //! ``` use axum::{ diff --git a/examples/query-params-with-empty-strings/src/main.rs b/examples/query-params-with-empty-strings/src/main.rs index aa42464384..0af20111d7 100644 --- a/examples/query-params-with-empty-strings/src/main.rs +++ b/examples/query-params-with-empty-strings/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-query-params-with-empty-strings +//! cd examples && cargo run -p example-query-params-with-empty-strings //! ``` use axum::{extract::Query, routing::get, Router}; diff --git a/examples/readme/src/main.rs b/examples/readme/src/main.rs index bdcb894557..a606893d60 100644 --- a/examples/readme/src/main.rs +++ b/examples/readme/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-readme +//! cd examples && cargo run -p example-readme //! ``` use axum::{ diff --git a/examples/reverse-proxy/src/main.rs b/examples/reverse-proxy/src/main.rs index ab551e5bce..849af0b3ac 100644 --- a/examples/reverse-proxy/src/main.rs +++ b/examples/reverse-proxy/src/main.rs @@ -4,7 +4,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-reverse-proxy +//! cd examples && cargo run -p example-reverse-proxy //! ``` use axum::{ diff --git a/examples/routes-and-handlers-close-together/src/main.rs b/examples/routes-and-handlers-close-together/src/main.rs index d294093024..5e52ad7b55 100644 --- a/examples/routes-and-handlers-close-together/src/main.rs +++ b/examples/routes-and-handlers-close-together/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-routes-and-handlers-close-together +//! cd examples && cargo run -p example-routes-and-handlers-close-together //! ``` use axum::{ diff --git a/examples/sessions/src/main.rs b/examples/sessions/src/main.rs index 079c0dc2b0..3251122c9a 100644 --- a/examples/sessions/src/main.rs +++ b/examples/sessions/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-sessions +//! cd examples && cargo run -p example-sessions //! ``` use async_session::{MemoryStore, Session, SessionStore as _}; diff --git a/examples/sqlx-postgres/src/main.rs b/examples/sqlx-postgres/src/main.rs index 3e8f052502..9d101618db 100644 --- a/examples/sqlx-postgres/src/main.rs +++ b/examples/sqlx-postgres/src/main.rs @@ -3,7 +3,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-sqlx-postgres +//! cd examples && cargo run -p example-sqlx-postgres //! ``` //! //! Test with curl: diff --git a/examples/sse/src/main.rs b/examples/sse/src/main.rs index 2bcab4c56d..d80f6685d5 100644 --- a/examples/sse/src/main.rs +++ b/examples/sse/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-sse +//! cd examples && cargo run -p example-sse //! ``` use axum::{ diff --git a/examples/static-file-server/src/main.rs b/examples/static-file-server/src/main.rs index 7e1034ba01..fad452066d 100644 --- a/examples/static-file-server/src/main.rs +++ b/examples/static-file-server/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-static-file-server +//! cd examples && cargo run -p example-static-file-server //! ``` use axum::{http::StatusCode, routing::get_service, Router}; diff --git a/examples/stream-to-file/src/main.rs b/examples/stream-to-file/src/main.rs index 6a8bad953c..407d379d6c 100644 --- a/examples/stream-to-file/src/main.rs +++ b/examples/stream-to-file/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-stream-to-file +//! cd examples && cargo run -p example-stream-to-file //! ``` use axum::{ diff --git a/examples/templates/src/main.rs b/examples/templates/src/main.rs index ec47a0836b..90ea206b75 100644 --- a/examples/templates/src/main.rs +++ b/examples/templates/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-templates +//! cd examples && cargo run -p example-templates //! ``` use askama::Template; diff --git a/examples/tls-rustls/src/main.rs b/examples/tls-rustls/src/main.rs index 862fca229d..18f74cb38d 100644 --- a/examples/tls-rustls/src/main.rs +++ b/examples/tls-rustls/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-tls-rustls +//! cd examples && cargo run -p example-tls-rustls //! ``` use axum::{routing::get, Router}; diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index c4fd3ddd94..9a33416be3 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -10,7 +10,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-todos +//! cd examples && cargo run -p example-todos //! ``` use axum::{ diff --git a/examples/tokio-postgres/src/main.rs b/examples/tokio-postgres/src/main.rs index 2abac5badb..4489f616df 100644 --- a/examples/tokio-postgres/src/main.rs +++ b/examples/tokio-postgres/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-tokio-postgres +//! cd examples && cargo run -p example-tokio-postgres //! ``` use axum::{ diff --git a/examples/tracing-aka-logging/src/main.rs b/examples/tracing-aka-logging/src/main.rs index edce16350b..8da6e5fed8 100644 --- a/examples/tracing-aka-logging/src/main.rs +++ b/examples/tracing-aka-logging/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-tracing-aka-logging +//! cd examples && cargo run -p example-tracing-aka-logging //! ``` use axum::{ diff --git a/examples/unix-domain-socket/src/main.rs b/examples/unix-domain-socket/src/main.rs index f23734e9a6..2f67a4c1e7 100644 --- a/examples/unix-domain-socket/src/main.rs +++ b/examples/unix-domain-socket/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-unix-domain-socket +//! cd examples && cargo run -p example-unix-domain-socket //! ``` #[cfg(unix)] diff --git a/examples/validator/src/main.rs b/examples/validator/src/main.rs index ed0d34631f..c8ce8c0884 100644 --- a/examples/validator/src/main.rs +++ b/examples/validator/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-validator +//! cd examples && cargo run -p example-validator //! //! curl '127.0.0.1:3000?name=' //! -> Input validation error: [name: Can not be empty] diff --git a/examples/versioning/src/main.rs b/examples/versioning/src/main.rs index 2cde3edb8a..48ade3c90c 100644 --- a/examples/versioning/src/main.rs +++ b/examples/versioning/src/main.rs @@ -1,7 +1,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-versioning +//! cd examples && cargo run -p example-versioning //! ``` use axum::{ diff --git a/examples/websockets/src/main.rs b/examples/websockets/src/main.rs index f38da380b6..9dab67a09e 100644 --- a/examples/websockets/src/main.rs +++ b/examples/websockets/src/main.rs @@ -3,7 +3,7 @@ //! Run with //! //! ```not_rust -//! cargo run -p example-websockets +//! cd examples && cargo run -p example-websockets //! ``` use axum::{