Skip to content
Permalink
Browse files
feat: include server streaming in rest descriptor (#414)
  • Loading branch information
noahdietz committed Nov 30, 2021
1 parent 10866d8 commit f5f6060a7c8ce8f24b6174b71a9145d96e1aefc1
@@ -536,6 +536,11 @@ public function isStreaming(): bool
$this->methodType === static::CLIENT_STREAMING;
}

public function isServerStreaming(): bool
{
return $this->methodType === static::SERVER_STREAMING;
}

public function isMixin(): bool
{
return $this->mixinServiceFullname !== null;
@@ -210,7 +210,7 @@ public static function generateRestConfig(ServiceDetails $serviceDetails, Servic
private static function compileRestConfigInterfaces(ServiceDetails $serviceDetails, ServiceYamlConfig $serviceYamlConfig)
{
return $serviceDetails->methods
->filter(fn ($method) => !is_null($method->httpRule) && !$method->isStreaming() && !$method->isMixin())
->filter(fn ($method) => !is_null($method->httpRule) && ($method->isServerStreaming() || !$method->isStreaming()) && !$method->isMixin())
->map(fn ($method) => [$serviceDetails->serviceName, $method, $method->httpRule])
->concat($serviceYamlConfig->httpRules->map(fn ($x) => [
Vector::new(explode('.', $x->getSelector()))->skipLast(1)->join('.'),
@@ -4,13 +4,19 @@ package testing.basicserverstreaming;

option php_namespace = "Testing\\BasicServerStreaming";

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";

service BasicServerStreaming {
option (google.api.default_host) = "serverstreaming.example.com";

rpc MethodServer(Request) returns(stream Response);
rpc MethodServer(Request) returns(stream Response) {
option (google.api.http) = {
post: "/path:serverStreaming"
body: "*"
};
};

rpc MethodEmpty(EmptyRequest) returns(stream Response);
}
@@ -1,5 +1,13 @@
<?php

return [
'interfaces' => [],
'interfaces' => [
'testing.basicserverstreaming.BasicServerStreaming' => [
'MethodServer' => [
'method' => 'post',
'uriTemplate' => '/path:serverStreaming',
'body' => '*',
],
],
],
];

0 comments on commit f5f6060

Please sign in to comment.