New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support HTTP/JSON via gRPC Gateway #188
Conversation
749f5fc
to
79dfd78
Compare
cmd/spicedb/serve.go
Outdated
@@ -346,28 +360,60 @@ func serveRun(cmd *cobra.Command, args []string) { | |||
} | |||
}() | |||
|
|||
// Start the REST gateway to serve HTTP/JSON. | |||
gatewaySrv, err := gateway.NewHttpServer(context.TODO(), gateway.Config{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should all be skippable; either if the http server endpoint is either empty or we add a new flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another idea is that we could run the dashboard, metrics, and HTTP API all on the same port.
go.mod
Outdated
// TODO(jschorr): Remove once https://github.com/dgraph-io/ristretto/pull/286 is merged | ||
replace github.com/dgraph-io/ristretto => github.com/josephschorr/ristretto v0.1.1-0.20211008180146-169a43af0a0d | ||
replace ( | ||
github.com/authzed/authzed-go => ../authzed-go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this change needs to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep this will remain a draft until the the following are merged:
abf1705
to
7c17418
Compare
internal/gateway/gateway.go
Outdated
// Addr is the address on which the HTTP server will be configured to listen. | ||
Addr string | ||
|
||
// UpstreamAddr is the address of the gRPC serve to which requests will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server
?
91266f8
to
fe9e718
Compare
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
gRPC Gateway performs this automatically. Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
This drops a local rewrite that used in development. Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
Signed-off-by: Jimmy Zelinskie <jimmy@zelinskie.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This change adds an additional port that the
spicedb serve
command uses to serve an HTTP/JSON API.It uses gRPC Gateway to forward requests to the
--grpc-addr
. Each RPC is represented as an HTTP POST with the protobuf messages encoded in JSON in the body of the request.Example usage:
TODO:
spicedb serve --http-addr