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 is a practical subset of the HttpRule spec โ€” enough for the common get: "/v1/x/{id}" / post: "/v1/x" body: "*" bindings:

  • verbs get/put/post/delete/patch and custom{kind},
  • additional_bindings (one level),
  • path templates: literal segments, {field} / {field=*} single-segment captures, and {field=**} (or a trailing segment) capturing the rest, with dotted field paths ({a.b}) binding nested fields,
  • body: "*" (whole message), body: "<field>" (a sub-message field), or none,
  • query params bound to (possibly nested) scalar/repeated fields.

Not yet handled (see BACKLOG): response_body, regex path patterns beyond */**, and non-scalar query binding.

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.