Skip to content

Commit 49d0e60

Browse files
committed
Add release notes and documentation.
1 parent b0fc660 commit 49d0e60

File tree

6 files changed

+100
-64
lines changed

6 files changed

+100
-64
lines changed

bake.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
# Released under the MIT License.
4+
# Copyright, 2024, by Samuel Williams.
5+
6+
# Update the project documentation with the new version number.
7+
#
8+
# @parameter version [String] The new version number.
9+
def after_gem_release_version_increment(version)
10+
context["releases:update"].call(version)
11+
context["utopia:project:readme:update"].call
12+
end

gems.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
group :maintenance, optional: true do
1111
gem "bake-modernize"
1212
gem "bake-gem"
13+
gem "bake-releases"
1314

1415
gem "utopia-project"
1516
end

guides/getting-started/readme.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Getting Started
2+
3+
This guide explains how to use the `protocol-http2` gem to implement a basic HTTP/2 client.
4+
5+
## Installation
6+
7+
Add the gem to your project:
8+
9+
``` bash
10+
$ bundle add protocol-http2
11+
```
12+
13+
## Usage
14+
15+
This gem provides a low-level implementation of the HTTP/2 protocol. It is designed to be used in conjunction with other libraries to provide a complete HTTP/2 client or server. However, it is straight forward to give examples of how to use the library directly.
16+
17+
### Client
18+
19+
Here is a basic HTTP/2 client:
20+
21+
``` ruby
22+
require 'async'
23+
require 'async/io/stream'
24+
require 'async/http/endpoint'
25+
require 'protocol/http2/client'
26+
27+
Async do
28+
endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
29+
30+
peer = endpoint.connect
31+
32+
puts "Connected to #{peer.inspect}"
33+
34+
# IO Buffering:
35+
stream = Async::IO::Stream.new(peer)
36+
37+
framer = Protocol::HTTP2::Framer.new(stream)
38+
client = Protocol::HTTP2::Client.new(framer)
39+
40+
puts "Sending connection preface..."
41+
client.send_connection_preface
42+
43+
puts "Creating stream..."
44+
stream = client.create_stream
45+
46+
headers = [
47+
[":scheme", endpoint.scheme],
48+
[":method", "GET"],
49+
[":authority", "www.google.com"],
50+
[":path", endpoint.path],
51+
["accept", "*/*"],
52+
]
53+
54+
puts "Sending request on stream id=#{stream.id} state=#{stream.state}..."
55+
stream.send_headers(headers, Protocol::HTTP2::END_STREAM)
56+
57+
puts "Waiting for response..."
58+
$count = 0
59+
60+
def stream.process_headers(frame)
61+
headers = super
62+
puts "Got response headers: #{headers} (#{frame.end_stream?})"
63+
end
64+
65+
def stream.receive_data(frame)
66+
data = super
67+
68+
$count += data.scan(/kittens/).count
69+
70+
puts "Got response data: #{data.bytesize}"
71+
end
72+
73+
until stream.closed?
74+
frame = client.read_frame
75+
end
76+
77+
puts "Got #{$count} kittens!"
78+
79+
puts "Closing client..."
80+
client.close
81+
end
82+
```

guides/links.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
getting-started:
2+
order: 1

readme.md

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -22,70 +22,9 @@ Or install it yourself as:
2222

2323
## Usage
2424

25-
Here is a basic HTTP/2 client:
25+
Please see the [project documentation](https://socketry.github.io/protocol-http2/) for more details.
2626

27-
``` ruby
28-
require 'async'
29-
require 'async/io/stream'
30-
require 'async/http/endpoint'
31-
require 'protocol/http2/client'
32-
33-
Async do
34-
endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens")
35-
36-
peer = endpoint.connect
37-
38-
puts "Connected to #{peer.inspect}"
39-
40-
# IO Buffering...
41-
stream = Async::IO::Stream.new(peer)
42-
43-
framer = Protocol::HTTP2::Framer.new(stream)
44-
client = Protocol::HTTP2::Client.new(framer)
45-
46-
puts "Sending connection preface..."
47-
client.send_connection_preface
48-
49-
puts "Creating stream..."
50-
stream = client.create_stream
51-
52-
headers = [
53-
[":scheme", endpoint.scheme],
54-
[":method", "GET"],
55-
[":authority", "www.google.com"],
56-
[":path", endpoint.path],
57-
["accept", "*/*"],
58-
]
59-
60-
puts "Sending request on stream id=#{stream.id} state=#{stream.state}..."
61-
stream.send_headers(headers, Protocol::HTTP2::END_STREAM)
62-
63-
puts "Waiting for response..."
64-
$count = 0
65-
66-
def stream.process_headers(frame)
67-
headers = super
68-
puts "Got response headers: #{headers} (#{frame.end_stream?})"
69-
end
70-
71-
def stream.receive_data(frame)
72-
data = super
73-
74-
$count += data.scan(/kittens/).count
75-
76-
puts "Got response data: #{data.bytesize}"
77-
end
78-
79-
until stream.closed?
80-
frame = client.read_frame
81-
end
82-
83-
puts "Got #{$count} kittens!"
84-
85-
puts "Closing client..."
86-
client.close
87-
end
88-
```
27+
- [Getting Started](https://socketry.github.io/protocol-http2/guides/getting-started/index) - This guide explains how to use the `protocol-http2` gem to implement a basic HTTP/2 client.
8928

9029
## Contributing
9130

releases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Releases
22

3-
## Unreleased
3+
## v0.22.0
44

55
### Added Priority Update Frame and Stream Priority
66

0 commit comments

Comments
 (0)