Skip to content

Commit 546e2ae

Browse files
committed
start writing the book
1 parent da3539c commit 546e2ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+786
-1
lines changed

.github/workflows/mdbook.yml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Deploy GitHub Pages
2+
on:
3+
push:
4+
branches: ["main", "book"]
5+
workflow_dispatch:
6+
7+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
14+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
# Build job
21+
build:
22+
runs-on: ubuntu-latest
23+
env:
24+
MDBOOK_VERSION: 0.4.44
25+
EMBEDIFY_VERSION: 0.2.11
26+
ALERTS_VERSION: 0.7.0
27+
steps:
28+
- name: Checkout site source
29+
uses: actions/checkout@v4
30+
31+
- name: Download mdBook
32+
run: |
33+
set -x
34+
wget https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz
35+
tar xzf mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz
36+
37+
wget https://github.com/MR-Addict/mdbook-embedify/releases/download/${EMBEDIFY_VERSION}/mdbook-embedify-${EMBEDIFY_VERSION}-x86_64-unknown-linux-gnu.zip
38+
unzip mdbook-embedify-${EMBEDIFY_VERSION}-x86_64-unknown-linux-gnu.zip
39+
mv mdbook-embedify-${EMBEDIFY_VERSION}-x86_64-unknown-linux-gnu/mdbook-embedify .
40+
41+
wget https://github.com/lambdalisue/rs-mdbook-alerts/releases/download/v${ALERTS_VERSION}/mdbook-alerts-x86_64-unknown-linux-gnu
42+
mv mdbook-alerts-x86_64-unknown-linux-gnu mdbook-alerts
43+
chmod +x mdbook-alerts
44+
45+
#- name: Setup Pages
46+
# uses: actions/configure-pages@v5
47+
48+
- name: Generate pages
49+
run: |
50+
export PATH=$PATH:.
51+
cp -f ECOSYSTEM.md book/src/ecosystem.md
52+
./mdbook build book/
53+
perl -i -p -e 's{href="index.html"}{href="."}g' book/book/toc.js
54+
perl -i -p -e 's{(href="[a-zA-Z0-9.][^"]+)\.html"}{$1"}g' book/book/toc.js
55+
find book/book/ -name *.html | xargs perl -i -p -e 's{href="index.html"}{href="."}g'
56+
find book/book/ -name *.html | xargs perl -i -p -e 's{(href="[a-zA-Z0-9.][^"]+)\.html"}{$1"}g'
57+
58+
- name: Upload artifact
59+
uses: actions/upload-pages-artifact@v3
60+
with:
61+
path: book/book/
62+
63+
# Deployment job
64+
deploy:
65+
environment:
66+
name: github-pages
67+
url: ${{ steps.deployment.outputs.page_url }}
68+
runs-on: ubuntu-latest
69+
needs: build
70+
steps:
71+
- name: Deploy to GitHub Pages
72+
id: deployment
73+
uses: actions/deploy-pages@v4
74+

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
target
22
.DS_Store
33
.vscode
4+
/book/book/
5+
*.swp

book/book.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[book]
2+
authors = ["Gábor Szabó"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "The Axum book"
7+
description = ""
8+
9+
# Add github icon to the menu
10+
[output.html]
11+
git-repository-url = "https://github.com/tokio-rs/axum"
12+
git-repository-icon = "fa-github"
13+
#edit-url-template = "https://github.com/tokio-rs/axum/edit/main/book/{path}"
14+
edit-url-template = "https://github.com/szabgab/axum/blob/book/book/{path}"
15+
16+
# Embedding and the footer
17+
[preprocessor.embedify]
18+
footer.enable = true
19+
footer.message = "Copyright © 2025 • Created with ❤️ by the authors"
20+

book/src/SUMMARY.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Summary
2+
3+
- [Axum](./index.md)
4+
- [ECOSYSTEM](./ecosystem.md)
5+
- [Hello World](./hello-world.md)
6+
7+
- [TODO](./todo.md)
8+
- [readme](./example-readme.md)
9+
- [form](./form.md)
10+
- [anyhow-error-response](./anyhow-error-response.md)
11+
- [auto-reload](./auto-reload.md)
12+
- [versioning](./versioning.md)
13+
- [validator](./validator.md)
14+
- [todos](./todos.md)
15+
- [templates](./templates.md)
16+
- [chat](./chat.md)
17+
- [compression](./compression.md)
18+
- [testing](./testing.md)
19+
- [cors](./cors.md)
20+
- [consume-body-in-extractor-or-middleware](./consume-body-in-extractor-or-middleware.md)
21+
- [customize-extractor-error](./customize-extractor-error.md)
22+
- [customize-path-rejection](./customize-path-rejection.md)
23+
- [dependency-injection](./dependency-injection.md)
24+
- [error-handling](./error-handling.md)
25+
- [global-404-handler](./global-404-handler.md)
26+
- [graceful-shutdown](./graceful-shutdown.md)
27+
- [handle-head-request](./handle-head-request.md)
28+
- [jwt](./jwt.md)
29+
- [http-proxy](./http-proxy.md)
30+
- [multipart-form](./multipart-form.md)
31+
- [query-params-with-empty-strings](./query-params-with-empty-strings.md)
32+
- [reqwest-response](./reqwest-response.md)
33+
- [print-request-response](./print-request-response.md)
34+
- [parse-body-based-on-content-type](./parse-body-based-on-content-type.md)
35+
- [unix-domain-socket](./unix-domain-socket.md)
36+
- [tracing-aka-logging](./tracing-aka-logging.md)
37+
- [tokio-redis](./tokio-redis.md)
38+
- [tokio-postgres](./tokio-postgres.md)
39+
- [tls-rustls](./tls-rustls.md)
40+
- [tls-graceful-shutdown](./tls-graceful-shutdown.md)
41+
- [testing-websockets](./testing-websockets.md)
42+
- [templates-minijinja](./templates-minijinja.md)
43+
- [stream-to-file](./stream-to-file.md)
44+
- [static-file-server](./static-file-server.md)
45+
- [sse](./sse.md)
46+
- [sqlx-postgres](./sqlx-postgres.md)
47+
- [simple-router-wasm](./simple-router-wasm.md)
48+
- [serve-with-hyper](./serve-with-hyper.md)
49+
- [routes-and-handlers-close-together](./routes-and-handlers-close-together.md)
50+
- [reverse-proxy](./reverse-proxy.md)
51+
- [request-id](./request-id.md)
52+
- [prometheus-metrics](./prometheus-metrics.md)
53+
- [oauth](./oauth.md)
54+
- [mongodb](./mongodb.md)
55+
- [low-level-rustls](./low-level-rustls.md)
56+
- [low-level-openssl](./low-level-openssl.md)
57+
- [low-level-native-tls](./low-level-native-tls.md)
58+
- [key-value-store](./key-value-store.md)
59+
- [websockets](./websockets.md)
60+
- [websockets-http2](./websockets-http2.md)
61+
- [diesel-async-postgres](./diesel-async-postgres.md)
62+
- [diesel-postgres](./diesel-postgres.md)
63+

book/src/anyhow-error-response.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# anyhow-error-response
2+
3+
```rust
4+
{{#include ../../examples/anyhow-error-response/src/main.rs }}
5+
```
6+
7+

book/src/auto-reload.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# auto-reload
2+
3+
```
4+
{{#include ../../examples/auto-reload/README.md }}
5+
```
6+
7+
```rust
8+
{{#include ../../examples/auto-reload/src/main.rs }}
9+
```
10+
11+

book/src/chat.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# chat
2+
3+
```rust
4+
{{#include ../../examples/chat/src/main.rs }}
5+
```
6+
7+
```html
8+
{{#include ../../examples/chat/chat.html }}
9+
```
10+

book/src/compression.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# compression
2+
3+
```markdown
4+
{{#include ../../examples/compression/README.md}}
5+
```
6+
7+
```rust
8+
{{#include ../../examples/compression/src/main.rs }}
9+
```
10+
11+
```rust
12+
{{#include ../../examples/compression/src/tests.rs }}
13+
```
14+
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# consume-body-in-extractor-or-middleware
2+
3+
```rust
4+
{{#include ../../examples/consume-body-in-extractor-or-middleware/src/main.rs }}
5+
```
6+
7+

book/src/cors.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# cors
2+
3+
```rust
4+
{{#include ../../examples/cors/src/main.rs }}
5+
```
6+
7+

book/src/customize-extractor-error.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# customize-extractor-error
2+
3+
```rust
4+
{{#include ../../examples/customize-extractor-error/README.md }}
5+
```
6+
7+
```rust
8+
{{#include ../../examples/customize-extractor-error/src/main.rs }}
9+
```
10+
```rust
11+
{{#include ../../examples/customize-extractor-error/src/custom_extractor.rs }}
12+
```
13+
```rust
14+
{{#include ../../examples/customize-extractor-error/src/derive_from_request.rs }}
15+
```
16+
```rust
17+
{{#include ../../examples/customize-extractor-error/src/with_rejection.rs }}
18+
```
19+
20+

book/src/customize-path-rejection.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# customize-path-rejection
2+
3+
4+
```rust
5+
{{#include ../../examples/customize-path-rejection/src/main.rs }}
6+
```
7+
8+

book/src/dependency-injection.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# dependency-injection
2+
3+
```rust
4+
{{#include ../../examples/dependency-injection/src/main.rs }}
5+
```
6+
7+

book/src/diesel-async-postgres.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# diesel-async-postgres
2+
3+
```rust
4+
{{#include ../../examples/diesel-async-postgres/src/main.rs }}
5+
```
6+
7+
```sql
8+
{{#include ../../examples/diesel-async-postgres/migrations/2023-03-14-180127_add_users/up.sql }}
9+
```
10+
11+
```sql
12+
{{#include ../../examples/diesel-async-postgres/migrations/2023-03-14-180127_add_users/down.sql }}
13+
```
14+
15+
16+

book/src/diesel-postgres.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# diesel-postgres
2+
3+
```rust
4+
{{#include ../../examples/diesel-postgres/src/main.rs }}
5+
```
6+
7+
```sql
8+
{{#include ../../examples/diesel-postgres/migrations/2023-03-14-180127_add_users/up.sql }}
9+
```
10+
11+
```sql
12+
{{#include ../../examples/diesel-postgres/migrations/2023-03-14-180127_add_users/down.sql }}
13+
```
14+
15+
16+

book/src/ecosystem.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ecosystem
2+
3+
Placeholder. This file is replaced in the CI bye the ECOSYSTEM.md in the source repository.

book/src/error-handling.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# error-handling
2+
3+
```rust
4+
{{#include ../..//examples/error-handling/src/main.rs }}
5+
```
6+
7+

book/src/example-readme.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Readme
2+
3+
4+
```toml
5+
{{#include ../../examples/readme/Cargo.toml }}
6+
```
7+
8+
```rust
9+
{{#include ../../examples/readme/src/main.rs }}
10+
```
11+

book/src/form.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Form
2+
3+
4+
```toml
5+
{{#include ../../examples/form/Cargo.toml }}
6+
```
7+
8+
```rust
9+
{{#include ../../examples/form/src/main.rs }}
10+
```

book/src/global-404-handler.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# global-404-handler
2+
3+
```rust
4+
{{#include ../../examples/global-404-handler/src/main.rs }}
5+
```
6+
7+

book/src/graceful-shutdown.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# graceful-shutdown
2+
3+
```rust
4+
{{#include ../../examples/graceful-shutdown/src/main.rs }}
5+
```
6+
7+

book/src/handle-head-request.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# handle-head-request
2+
3+
```rust
4+
{{#include ../../examples/handle-head-request/src/main.rs }}
5+
6+
```
7+
8+

0 commit comments

Comments
 (0)