Skip to main content

Module httprule

Module httprule 

Source
Expand description

google.api.http transcoding: map REST-style (HTTP method, path) requests onto gRPC methods, binding path segments, query params, and the request body into the request message.

This implements HttpRule; doc/HTTPRULE_GAPS.md is the authoritative statement of the boundary, and as of 2026-07-28 there are no functional gaps in the method option — only HttpRule.selector (service-config rules), declined.

go/webnext/httprule.go is the deliberately parallel port of this file — same segment/body model, same matching order, same coercion table — so the two implementations can be compared side by side. Change one, change the other in the same commit.

Two ideas carry most of the weight:

(Segment and set_from_json below are private, so they are named here rather than linked — this is a tour of the file, not of the public API.)

  • Captures are patterns, not segments. Segment::Capture holds its own sub-pattern, so {f}, {f=**} and {f=shelves/*/books/*} are one case rather than three. Splitting is brace-aware for exactly that reason.
  • Conversions belong to the JSON decoder. Anything without a scalar form — bytes, the well-known types, a body: naming a non-message field — is set by handing its protobuf-JSON text to the decoder rather than parsed here. See set_from_json.

Structs§

HttpCall
The transcoded call: which gRPC method to invoke and the encoded request.
HttpRouter
A table of HTTP bindings compiled from a descriptor pool.
WsBinding
A WebSocket route resolved from an annotation URL: the target gRPC method plus the path/query bindings, used to build each streamed request message.