Skip to content

Commit 09707df

Browse files
committed
Documentation.
1 parent 7d07487 commit 09707df

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/protocol/http/methods.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,23 @@
55

66
module Protocol
77
module HTTP
8-
# All supported HTTP methods, as outlined by <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods>.
8+
# Provides a convenient interface for commonly supported HTTP methods.
9+
#
10+
# | Method Name | Request Body | Response Body | Safe | Idempotent | Cacheable |
11+
# | ----------- | ------------ | ------------- | ---- | ---------- | --------- |
12+
# | GET | Optional | Yes | Yes | Yes | Yes |
13+
# | HEAD | Optional | No | Yes | Yes | Yes |
14+
# | POST | Yes | Yes | No | No | Yes |
15+
# | PUT | Yes | Yes | No | Yes | No |
16+
# | DELETE | Optional | Yes | No | Yes | No |
17+
# | CONNECT | Optional | Yes | No | No | No |
18+
# | OPTIONS | Optional | Yes | Yes | Yes | No |
19+
# | TRACE | No | Yes | Yes | Yes | No |
20+
# | PATCH | Yes | Yes | No | No | No |
21+
#
22+
# These methods are defined in this module using lower case names. They are for convenience only and you should not overload those methods.
23+
#
24+
# See <https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods> for more details.
925
class Methods
1026
# The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
1127
GET = 'GET'

lib/protocol/http/middleware.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010

1111
module Protocol
1212
module HTTP
13+
# The middleware interface provides a convenient wrapper for implementing HTTP middleware.
14+
#
15+
# A middleware instance generally needs to respond to two methods:
16+
#
17+
# - `call(request)` -> `response`
18+
# - `close()`
19+
#
20+
# The call method is called for each request. The close method is called when the server is shutting down.
21+
#
22+
# You do not need to use the Middleware class to implement middleware. You can implement the interface directly.
1323
class Middleware < Methods
1424
# Convert a block to a middleware delegate.
1525
def self.for(&block)

0 commit comments

Comments
 (0)