Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Endpoints custom domain workaround

We have an AppEngine app with that we would like to use with Google Endpoints. We need to support a web client as well as mobile clients which is what makes Endpoints attractive to us since we can easily generate Android and iOS client APIs.

The problem is that cloud endpoints currently don't support custom domains, so our web client cannot directly communicate with the endpoints (the mobile clients do not have this issue).

Here is what we've tried already:

  • CORS requests from the client to the appspot.com domain. The problem with this is since our request do not meet the requirements for simple CORS (custom headers, cookies, etc.), a preflight request must be sent with every request, which slows everything down

  • Client makes request to our custom domain which in turn makes a request to the appspot endpoint. Again, the extra request is not good for performance

  • We've also tried setting up a duplicate Jersey REST API just for the web client. We double annotate all our methods (once for Cloud Endpoints and once for Jersey) and the web client accesses the Jersey API and the mobile clients access the Endpoints API. This works pretty well except that Jersey and Endpoints use different exceptions. So if we want to throw a 404 Endpoints exception that will mess up the Jersey response and vice versa.

Are there any other options? We want to use the power of Endpoints for generating mobile clients but also get around the custom domain limitation for the web client.

like image 404
Pixel Elephant Avatar asked Feb 11 '14 16:02

Pixel Elephant


1 Answers

We ended up ditching Cloud Endpoints entirely and went with a pure Jersey REST API instead.

To deal with our need to generate mobile clients for the API, we annotated our API with Swagger. As an added bonus, Swagger seems to support more client generation than Cloud Endpoints and also makes it relatively easy to setup your own client generation from a template if your target language isn't directly supported.

Jersey + Swagger was not as easy to setup as Cloud Endpoints, but it is more customizable and allowed us to get around the custom domain restriction imposed by Cloud Endpoints.

like image 172
Pixel Elephant Avatar answered Oct 03 '22 06:10

Pixel Elephant