{"action":"created","issue":{"url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway/issues/652","repository_url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway","labels_url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway/issues/652/labels{/name}","comments_url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway/issues/652/comments","events_url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway/issues/652/events","html_url":"https://github.com/grpc-ecosystem/grpc-gateway/issues/652","id":323440803,"node_id":"MDU6SXNzdWUzMjM0NDA4MDM=","number":652,"title":"Access to raw post body","user":{"login":"nscharfe","id":918293,"node_id":"MDQ6VXNlcjkxODI5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/918293?v=4","gravatar_id":"","url":"https://api.github.com/users/nscharfe","html_url":"https://github.com/nscharfe","followers_url":"https://api.github.com/users/nscharfe/followers","following_url":"https://api.github.com/users/nscharfe/following{/other_user}","gists_url":"https://api.github.com/users/nscharfe/gists{/gist_id}","starred_url":"https://api.github.com/users/nscharfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nscharfe/subscriptions","organizations_url":"https://api.github.com/users/nscharfe/orgs","repos_url":"https://api.github.com/users/nscharfe/repos","events_url":"https://api.github.com/users/nscharfe/events{/privacy}","received_events_url":"https://api.github.com/users/nscharfe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-05-16T01:47:23Z","updated_at":"2018-10-18T18:36:27Z","closed_at":null,"author_association":"NONE","body":"I'm implementing a webhook handler and need to perform a checksum on the raw post body that is received but cannot figure out how to access it.\r\n\r\nSinatra Equivalent:\r\n```\r\npost '/my/webhook/url' do\r\n    body = request.body.read\r\n    ...\r\nend\r\n```\r\n\r\nDjango Equivalent:\r\n```\r\ndef my_webhook_view(request):\r\n  body = request.body\r\n  ...\r\n```\r\n\r\nNode Equivalent:\r\n```\r\napp.use(require('body-parser').raw({type: '*/*'}));\r\n\r\napp.post('/my/webhook/url', function(request, response) {\r\n  body = request.body;\r\n  ...\r\n});\r\n```\r\n\r\n---------------------------------------\r\n\r\nMy original implementation was:\r\n\r\n```\r\nmessage WebhookRequest {\r\n    string body = 1;\r\n}\r\n\r\nrpc HandleWebhook(WebhookRequest) returns (google.protobuf.Empty) {\r\n    option (google.api.http) = {\r\n        post: \"/public/processWebhook\"\r\n        body: \"body\"\r\n    };\r\n}\r\n```\r\n\r\nThis works as expected if the post body is explicitly a string. However, if the post body is a json object, it tries to unmarshal it into `body`, which is a string, and fails.\r\n\r\nEx post bodies: \r\n`\"test\"` => is unmarshaled into `WebhookRequest.body` appropriately.\r\n`{\"test\": \"val\"}` => `\"error\": \"json: cannot unmarshal object into Go value of type string\"`\r\n`\"{\\\"test\\\": \\\"val\\\"}\"` => is unmarshaled into `WebhookRequest.body`\r\n\r\nSince this is a webhook, I have no control over how the post body is constructed -- its not possible to encode it as a string before sending it over the wire.\r\n\r\nI've tried updating `WebhookRequest` to hold a `google.protobuf.Struct`, `google.protobuf.Any` etc but none of them are able to preserve the post body in its raw form.\r\n\r\nI'd imagine its possible to accomplish what I want by [customizing message serialization](https://grpc-ecosystem.github.io/grpc-gateway/docs/customizingyourgateway.html) but that feels like overkill.\r\n\r\nAny help would be greatly appreciated. I'd imagine I'm overlooking something obvious.\r\n\r\nThanks in advance!\r\n"},"comment":{"url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway/issues/comments/431116744","html_url":"https://github.com/grpc-ecosystem/grpc-gateway/issues/652#issuecomment-431116744","issue_url":"https://api.github.com/repos/grpc-ecosystem/grpc-gateway/issues/652","id":431116744,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTExNjc0NA==","user":{"login":"nscharfe","id":918293,"node_id":"MDQ6VXNlcjkxODI5Mw==","avatar_url":"https://avatars2.githubusercontent.com/u/918293?v=4","gravatar_id":"","url":"https://api.github.com/users/nscharfe","html_url":"https://github.com/nscharfe","followers_url":"https://api.github.com/users/nscharfe/followers","following_url":"https://api.github.com/users/nscharfe/following{/other_user}","gists_url":"https://api.github.com/users/nscharfe/gists{/gist_id}","starred_url":"https://api.github.com/users/nscharfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nscharfe/subscriptions","organizations_url":"https://api.github.com/users/nscharfe/orgs","repos_url":"https://api.github.com/users/nscharfe/repos","events_url":"https://api.github.com/users/nscharfe/events{/privacy}","received_events_url":"https://api.github.com/users/nscharfe/received_events","type":"User","site_admin":false},"created_at":"2018-10-18T18:36:27Z","updated_at":"2018-10-18T18:36:27Z","author_association":"NONE","body":"yep, feel free. thank you!"}}
{"actor":{"display_login":"nscharfe"}}