Skip to content

[proxy] Handle both gRPC and HTTP requests against public-api #13582

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

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion components/proxy/conf/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,15 @@ api.{$GITPOD_DOMAIN} {
output stdout
}

reverse_proxy h2c://public-api-server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:9001
@grpc protocol grpc

handle @grpc {
# gRPC traffic goes to gRPC server
reverse_proxy h2c://public-api-server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:9001
}

# Non-grpc traffic goes to an HTTP server
reverse_proxy public-api-server.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:9002
}


Expand Down
3 changes: 3 additions & 0 deletions components/public-api-server/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func Start(logger *logrus.Entry, version string, cfg *config.Configuration) erro
log.Info("No stripe webhook secret is configured, endpoints will return NotImplemented")
}

srv.HTTPMux().Handle("/test", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`test`))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll remove this once we've got actual endpoints implemented, for now this acts as a quick check the server is reachable.

}))
srv.HTTPMux().Handle("/stripe/invoices/webhook", handlers.ContentTypeHandler(stripeWebhookHandler, "application/json"))

if registerErr := register(srv, gitpodAPI, srv.MetricsRegistry()); registerErr != nil {
Expand Down