QeweneyRuby HTTP 请求/响应 API
Qeweney 是一个功能丰富的 Ruby HTTP 请求/响应 API。
Qeweney 提供了统一的 API 来处理服务器端的 HTTP 请求和响应。Qeweney 定义了一个统一的适配器接口,允许处理传入的 HTTP 请求并通过任何协议或传输发送 HTTP 响应,无论是 HTTP/1、HTTP/2 还是 Rack 接口。
Qeweney 主要设计为与 Tipi一起使用,但也可以直接在 Rack 应用程序中使用,或驱动 Rack 应用程序。
特性:
- 适用于不同的 Web 服务器 API,尤其是 Tipi、Digital Fabric 和 Rack。
- Transport-agnostic
- 受 Roda 启发的高性能路由 API。
- 用于从 HTTP 请求中提取数据的丰富 API:表单解析、cookie、文件上传等。
- 用于构建 HTTP 响应的丰富 API:流响应、HTTP 升级、静态文件服务、延迟和 gzip 编码、缓存等。
- 适用于阻塞和非阻塞并发模型。
- 允许在读取和解析请求正文之前处理请求。
The Qeweney Adapter Interface
class AdapterInterface
# Reads a chunk from the request body
# @req [Qeweney::Request] request for which the chunk is to be read
def get_body_chunk(req)
end
# Send a non-streaming response
# @req [Qeweney::Request] request for which the response is sent
# @body [String, nil] response body
# @headers [Hash] response headers
def respond(req, body, headers)
end
# Send only headers
# @req [Qeweney::Request] request for which the response is sent
# @headers [Hash] response headers
# @empty_response [boolean] whether response is empty
def send_headers(req, headers, empty_response: nil)
end
# Send a body chunk (this implies chunked transfer encoding)
# @req [Qeweney::Request] request for which the response is sent
# @body [String, nil] chunk
# @done [boolean] whether response is finished
def send_chunk(req, body, done: false)
end
# Finishes response
# @req [Qeweney::Request] request for which the response is sent
def finish(req)
end
end
评论
