class Bezel::Plug::RequestId
include Bezel::Plug
Gives each request an id: the request's X-Request-Id when it is a
sane one (20 to 200 characters of letters, digits, +, /, =, _
and -, as a proxy in front makes), else a new random one. The id is
Conn#request_id and goes back in the response's X-Request-Id, so
that a log line and a client's report can be matched.
conn = Bezel::Plug::RequestId.new.call(Bezel::Conn.build(HTTP::Server::Request.get("/")))
(conn.request_id || "").size # => 22
conn.resp_headers["x-request-id"] == conn.request_id # => true
Class methods
def self.new(header: String = …) -> Bezel::Plug::RequestId
The plug, reading and writing the header header.
def self.valid?(id: String) -> Bool
Whether id may be kept.
def self.generate -> String
A new id: 16 random bytes in URL-safe Base64.
Methods
def header -> String
The header read and written.
def call(conn: Bezel::Conn) -> Bezel::Conn
The connection changed by this plug.
from Bezel::Plug