This PR does not require any changes to user code.
Changes
[x] Change rpc/3 to rpc/4 to accept options
[x] Use routes instead of finding server based on path
[x] HttpRule template parsing
[x] static segments
[x] variables
[x] * (match single URL segment)
[x] ** (zero or more URL paths, needs to be last part of URL)
[x] variable path segments
[x] field paths
[x] HttpRule spec -> server route
[x] JSON request body into request struct
[x] Merge bound path params to request struct
[x] Merge query string to request struct
[x] Use accept header instead of content-type in get requests
[x] Map request body using (HttpRule.body)
[x] Map response body using (HttpRule.response_body)
[x] Allow JSON requests without HttpRule options
[x] Change to include http request method in GRPC.Server.__call___ (to differenciate between GET /v1/messagesPOST /v1/messages)
[x] Unary
[x] Server streaming (Newline-delimited JSON)
[x] gRPC transcode integration test
[x] gRPC transcode example
[x] Docs
Routing
The path template syntax that can be described using Google.Api.HttpRule can not be expressed using the default :cowboy_router middleware. GRPC.Server.Adapters.Cowboy.Router implements the :cowboy_middleware behaviour and lifts most of its functionality from :cowboy_router with the difference being that it's using GRPC.Service.Router which can build and match Google.Api.HttpRule path templates.
The new routing should be able to match all rules described in the path template syntax:
Support for gRPC transcoding.
This feature is opt-in using the
http_transcode
option in the server definition:Request/response mapping can be controlled by adding
grpc-gateway
annotations to your proto definition:This PR does not require any changes to user code.
Changes
rpc/3
torpc/4
to accept options*
(match single URL segment)**
(zero or more URL paths, needs to be last part of URL)accept
header instead ofcontent-type
in get requestsHttpRule.body
)HttpRule.response_body
)HttpRule
optionsGRPC.Server.__call___
(to differenciate betweenGET /v1/messages
POST /v1/messages
)Routing
The path template syntax that can be described using
Google.Api.HttpRule
can not be expressed using the default:cowboy_router
middleware.GRPC.Server.Adapters.Cowboy.Router
implements the:cowboy_middleware
behaviour and lifts most of its functionality from:cowboy_router
with the difference being that it's usingGRPC.Service.Router
which can build and matchGoogle.Api.HttpRule
path templates.The new routing should be able to match all rules described in the path template syntax:
Of course regular gRPC request paths are also matched i.e
POST helloworld.Greeter/SayHello
.