Skip to content

docs(server): update server guides to 1.0 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
107cef7
docs(server): update hello-world guide to 1.0
oddgrd Dec 3, 2022
c32883a
docs(server): fix broken links, codeblock comments
oddgrd Dec 6, 2022
df11697
docs(server): first iteration of echo guide
oddgrd Dec 11, 2022
2f903a9
docs(server): clean up deps
oddgrd Dec 11, 2022
383f237
refactor(server): rephrasing
oddgrd Dec 11, 2022
e77a968
Merge branch 'master' into feat/update-server-guides
oddgrd Dec 14, 2022
4ac902e
refactor: split guides up into legacy and master
oddgrd Dec 14, 2022
2560633
ci: rewrite script to test master and legacy
oddgrd Dec 14, 2022
8099d9d
fix: master hello-world, revert legacy guides
oddgrd Dec 14, 2022
7ea273f
fix(server): echo guide doc test errors
oddgrd Dec 16, 2022
ab5238a
feat: create new collection for 1.0 guides
oddgrd Dec 16, 2022
d7feeab
ci: update script to check both collections
oddgrd Dec 16, 2022
4800d39
feat(server): remove graceful-shutdoown from stable guides
oddgrd Dec 17, 2022
de61a0c
feat: 0.14/1.0 tabs, update 1.0 guides index
oddgrd Dec 17, 2022
e00165c
fix: incorrect links in 0.14 guides
oddgrd Dec 17, 2022
59a689b
feat: rename old guides to legacy
oddgrd Dec 17, 2022
7b3978f
feat: rename _guides to _legacy
oddgrd Dec 17, 2022
0f155d8
feat: update main index to 1.0
oddgrd Dec 17, 2022
d182f50
feat: link to correct api docs in guide main index
oddgrd Dec 17, 2022
65477a2
feat: add note about /stable being 1.0 docs
oddgrd Dec 17, 2022
58fb348
feat: add note to home about transition to 1.0
oddgrd Dec 17, 2022
528e718
feat: add link to 1.0 roadmap
oddgrd Dec 17, 2022
cfcb295
feat: use versions in guide urls
oddgrd Dec 20, 2022
ed0c409
feat: redirect from old urls to new 0.14 urls
oddgrd Dec 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 41 additions & 28 deletions .github/workflows/check_guides.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,50 @@
#!/bin/sh

if [ ! -e tmp/Cargo.toml ]; then
if [ ! -d tmp ]; then
cargo new tmp
else
cargo init tmp
fi
cat >> tmp/Cargo.toml <<-EOF
futures = "0.3"
hyper = { version = "0.14", features = ["full"] }
hyper-tls = "0.5"
tokio = { version = "1", features = ["full"] }
for value in legacy stable
do
if [ ! -e "$value/Cargo.toml" ]; then
if [ ! -d $value ]; then
cargo new $value
else
cargo init $value
fi
if [ $value = legacy ]; then
cat >> "$value/Cargo.toml" <<-EOF
futures = "0.3"
hyper = { version = "0.14", features = ["full"] }
hyper-tls = "0.5"
tokio = { version = "1", features = ["full"] }
EOF
cargo build --manifest-path tmp/Cargo.toml
fi

test_file() {
echo "Testing: $f"
rustdoc --edition 2018 --test $1 -L tmp/target/debug/deps
}
cargo build --manifest-path "$value/Cargo.toml"
fi
if [ $value = stable ]; then
cat >> "$value/Cargo.toml" <<-EOF
hyper = { version = "1.0.0-rc.1", features = ["full"] }
tokio = { version = "1", features = ["full"] }
http-body-util = "0.1.0-rc.1"
EOF
cargo build --manifest-path "$value/Cargo.toml"
fi
fi

if [ -n "$1" ]; then
test_file $1
exit $?
fi
test_file() {
echo "Testing: $f"
rustdoc --edition 2018 --test $1 -L "$value/target/debug/deps"
}

status=0
for f in `git ls-files | grep '\.md$'`; do
test_file $f
s=$?
if [ "$s" != "0" ]; then
status=$s
if [ -n "$1" ]; then
test_file $1
exit $?
fi

status=0
for f in `git ls-files | grep "^_$value\/.*\.md$"`; do
test_file $f
s=$?
if [ "$s" != "0" ]; then
status=$s
fi
done
done

exit $status
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Gemfile*
_site*
.sass-cache
tmp/
/legacy
/stable
25 changes: 21 additions & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ url: "https://hyper.rs" # the base hostname & protocol for your site
defaults:
-
scope:
path: "_guides"
path: "_legacy/"
type: "guides"
values:
layout: "guide"
-

scope:
path: "_stable/"
type: "guides"
values:
layout: "guide"


collections:
guides:
permalink: /:collection/:path/
legacy:
permalink: /guides/0.14/:path/
output: true
stable:
permalink: /guides/1/:path/
output: true
posts:
permalink: /blog/:year/:month/:day/:title/
Expand All @@ -31,7 +42,13 @@ relative_links:
enabled: true
collections: true

docs_url: https://docs.rs/hyper/0.14.*
plugins:
- jekyll-redirect-from

docs_url: https://docs.rs/hyper/1.0.0-rc.1
examples_url: https://github.com/hyperium/hyper/tree/master/examples
futures_url: https://docs.rs/futures/0.3.*
hyper_tls_url: https://docs.rs/hyper-tls/*

legacy_docs_url: https://docs.rs/hyper/0.14.23
legacy_examples_url: https://github.com/hyperium/hyper/tree/0.14.x/examples
File renamed without changes.
19 changes: 19 additions & 0 deletions _data/stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- title: Guide
path: ""
guides:
- server
- client

- title: Server
path: "/server"
guides:
- hello-world
- echo
- graceful-shutdown

- title: Client
path: "/client"
guides:
- basic
- advanced
- configuration
20 changes: 14 additions & 6 deletions _includes/guide_ul.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
<section class="guide-topic">
<h4 class="guide-topic-title">{{ topic.title }}</h4>
<ul class="nav">
{% for guide in topic.guides %}
{% assign guide_url = guide | prepend:"/" | prepend: topic.path | prepend:"/guides" | append:"/" %}
{% assign p = site.guides | where:"url", guide_url | first %}
<li {% if guide_url == page.url %}class="active"{% endif %}><a href="{{ p.url }}">{{ p.title }} </a></li>
{% endfor %}
{% if page.collection == "legacy" %}
{% for guide in topic.guides %}
{% assign guide_url = guide | prepend:"/" | prepend: topic.path | prepend:"/guides/0.14" | append:"/" %}
{% assign p = site.legacy | where:"url", guide_url | first %}
<li {% if guide_url == page.url %}class="active"{% endif %}><a href="{{ p.url }}">{{ p.title }} </a></li>
{% endfor %}
{% elsif page.collection == "stable" %}
{% for guide in topic.guides %}
{% assign guide_url = guide | prepend:"/" | prepend: topic.path | prepend:"/guides/1" | append:"/" %}
{% assign p = site.stable | where:"url", guide_url | first %}
<li {% if guide_url == page.url %}class="active"{% endif %}><a href="{{ p.url }}">{{ p.title }} </a></li>
{% endfor %}
{% endif %}
</ul>
</section>
</section>
3 changes: 2 additions & 1 deletion _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<li class="nav-item">
<a class="navbar-brand" href="/">hyper.rs</a>
</li>
<li class="nav-item"><a class="nav-link" href="/guides">Guides</a></li>
<li class="nav-item"><a class="nav-link" href="/guides/1">1.0 Guides</a></li>
<li class="nav-item"><a class="nav-link" href="/guides/0.14">0.14 Guides</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/hyperium/hyper">Source</a></li>
</ul>
</div>
Expand Down
27 changes: 20 additions & 7 deletions _layouts/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,27 @@ <h1>{{ page.title }}</h1>
<div class="row">
<aside class="col-md-3 hyper-sidebar">
<nav>
{% assign topics = site.data.guides | first %}
{% for guides in topics.guides %}
{% assign topic_sub_url = guides | prepend:"/" %}
{% assign topic = site.data.guides | where: "path", topic_sub_url | first %}
{% include guide_ul.html topic=topic %}
{% endfor %}
{% if page.collection == "legacy" %}
{% assign topics = site.data.legacy | first %}
{% for guides in topics.guides %}
{% assign topic_sub_url = guides | prepend:"/" %}
{% assign topic = site.data.legacy | where: "path", topic_sub_url | first %}
{% include guide_ul.html topic=topic %}
{% endfor %}
{% elsif page.collection == "stable" %}
{% assign topics = site.data.stable | first %}
{% for guides in topics.guides %}
{% assign topic_sub_url = guides | prepend:"/" %}
{% assign topic = site.data.stable | where: "path", topic_sub_url | first %}
{% include guide_ul.html topic=topic %}
{% endfor %}
{% endif %}
<h4 class="guide-topic-title">
<a href="{{ site.docs_url }}">API Reference</a>
{% if page.collection == "legacy" %}
<a href="{{ site.legacy_docs_url }}">API Reference</a>
{% elsif page.collection == "stable" %}
<a href="{{ site.docs_url }}">API Reference</a>
{% endif %}
</h4>
</nav>
</aside>
Expand Down
13 changes: 10 additions & 3 deletions _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
<div class="container">
<h1 class="hyper-logo">hyper</h1>
<p>Fast and safe HTTP for the Rust language.</p>
<p><a href="/guides" class="btn hyper-getstarted">Get Started</a></p>
<p><a href="/guides/1" class="btn hyper-getstarted">Get Started</a></p>
</div>
</section>
<section class="container">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<p class="lead">
<b>Note:</b> hyper is planning a stable <code>1.0</code> release at the end of January 2023.
These guides will be gradually transitioned to <code>1.0</code>, but if you're looking for
guides for <code>0.14</code> you can find them <a href="/guides/0.14">here</a>. If you'd like to
learn more about the move to <code>1.0</code>,
<a href="https://seanmonstar.com/post/680802159018803200/hyper-10-roadmap">this</a> is a good place to start.
</p>
<p class="lead">hyper is a fast HTTP implementation written in and for Rust.</p>
<ul>
<li>A <strong>Client</strong> for talking to web services.</li>
Expand Down
7 changes: 5 additions & 2 deletions _guides/client/advanced.md → _legacy/client/advanced.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: Advanced Client Usage
layout: guide
redirect_from:
- /guides/client/advanced
---

Once you've done all the setup in the [simple guide][], you probably
Expand Down Expand Up @@ -110,5 +113,5 @@ let (ip, headers) = futures::try_join!(ip_fut, headers_fut)?;
```

[simple guide]: ./basic.md
[Request]: {{ site.docs_url }}/hyper/struct.Request.html
[Method]: {{ site.docs_url }}/hyper/struct.Method.html
[Request]: {{ site.legacy_docs_url }}/hyper/struct.Request.html
[Method]: {{ site.legacy_docs_url }}/hyper/struct.Method.html
11 changes: 7 additions & 4 deletions _guides/client/basic.md → _legacy/client/basic.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: Getting Started with a Client
layout: guide
redirect_from:
- /guides/client/basic
---

To start with, we'll just get a simple `GET` request to a webpage working,
Expand Down Expand Up @@ -112,9 +115,9 @@ while let Some(chunk) = resp.body_mut().data().await {

And that's it! You can see the [full example here][example].

[Client]: {{ site.docs_url }}/hyper/client/struct.Client.html
[Client]: {{ site.legacy_docs_url }}/hyper/client/struct.Client.html
[Tokio]: https://tokio.rs
[Tokio-Futures]: https://tokio.rs/tokio/tutorial/async
[StatusCode]: {{ site.docs_url }}/hyper/struct.StatusCode.html
[Response]: {{ site.docs_url }}/hyper/struct.Response.html
[example]: {{ site.examples_url }}/client.rs
[StatusCode]: {{ site.legacy_docs_url }}/hyper/struct.StatusCode.html
[Response]: {{ site.legacy_docs_url }}/hyper/struct.Response.html
[example]: {{ site.legacy_examples_url }}/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: Client Configuration
layout: guide
redirect_from:
- /guides/client/configuration
---

## Using TLS
Expand Down Expand Up @@ -39,5 +42,5 @@ ideas of things that could be connectors:
- Proxies
- In-memory streams (such as for testing)

[`Client`]: {{ site.docs_url }}/hyper/client/struct.Client.html
[`Client`]: {{ site.legacy_docs_url }}/hyper/client/struct.Client.html
[hyper-tls]: {{ site.hyper_tls_url }}
4 changes: 3 additions & 1 deletion _guides/client/index.md → _legacy/client/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Client Guides
permalink: /guides/client/
permalink: /0.14/client
redirect_from:
- /guides/client/
---

This is just placeholder page. It should probably become a table of
Expand Down
6 changes: 4 additions & 2 deletions _guides/index.md → _legacy/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
title: Getting Started
layout: guide
permalink: /guides/
permalink: /guides/0.14/
redirect_from:
- /guides/
---

hyper is an HTTP library for the Rust language.
Expand All @@ -18,6 +20,6 @@ hyper = "0.14"

You could also look at the [generated API documentaton][docs].

[docs]: {{ site.docs_url }}
[docs]: {{ site.legacy_docs_url }}
[Server guide]: server/hello-world.md
[Client guide]: client/basic.md
5 changes: 4 additions & 1 deletion _guides/server/echo.md → _legacy/server/echo.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: Echo, echo, echo
layout: guide
redirect_from:
- /guides/server/echo
---

You already have a [Hello World server](hello-world.md)? Excellent! Usually,
Expand Down Expand Up @@ -197,5 +200,5 @@ We want to concatenate the request body, and map the result into our `reverse` f

You can see a compiling [example here][example].

[example]: {{ site.examples_url }}/echo.rs
[example]: {{ site.legacy_examples_url }}/echo.rs
[future-crate]: https://github.com/rust-lang-nursery/futures-rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Gracefully Shutdown a Server
layout: guide
redirect_from:
- /guides/server/graceful-shutdown
---

hyper `Server`s have the ability to "gracefully" shutdown. This means stopping to accept new requests, and shutting down once all in-progress requests have completed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: Getting Started with a Server
layout: guide
redirect_from:
- /guides/server/hello-world
---

Let's start by making a "Hello, World!" server, and expand from there.
Expand Down Expand Up @@ -94,5 +96,5 @@ async fn main() {

To see all the snippets put together, check out the [full example][example]!

[service]: {{ site.docs_url }}/hyper/service/trait.Service.html
[example]: {{ site.examples_url }}/hello.rs
[service]: {{ site.legacy_docs_url }}/hyper/service/trait.Service.html
[example]: {{ site.legacy_examples_url }}/hello.rs
9 changes: 9 additions & 0 deletions _legacy/server/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Server Guides
permalink: /0.14/server
redirect_from:
- /guides/server/
---

This is just placeholder page. It should probably become a table of
contents for the server guides.
Loading