Does my default app have to be deployed to appspot

2019-07-29 06:00发布

问题:

I asked a question about the default app as it related to microservices on app engine and got a great response here, but I have another question relating to this.

Does my default app have to be accessible via appspot.com? when i run the deploy command thats where it puts it, but I'd rather have it not accessible like that. I really just want a semi-empty (like hello world sized) app that satisfies the default app requirement.

It does seem like google is shoehorning multi-app/microservices into an environment that was originally setup to only serve a single web facing app backed by other modules. It seems very ungraceful and hacky.

回答1:

You can customize your app to perform differently based on the URL that was used.

For example, you can use domain specific routes with webapp2 or you can check the domain in your handler by checking the value of self.request.url and responding accordingly.

You could for example, have myapp.appspot.com return a 404 but have www.mydomain.com provide content to users.



回答2:

It depends what you mean by "accessible".

Yes, the app will have a presence on appspot.com, in the sense that requests can make it to some instance of some version of some service inside your app, based on the Routing via URL rules, the most generic ones being:

Sends a request to the named service, version, and instance:

https://instance-dot-version-dot-service-dot-app-id.appspot.com
http://instance.version.service.my-custom-domain.com

Also, from Default service:

The default service is defined by explicitly giving a service the name "default," or by not including the name parameter in the service's config file. Requests that specify no service or an invalid service are routed to the default service. You can designate a default version for a service, when appropriate, in the Google Cloud Platform Console versions tab.

But what your app code responds to such requests is really up to you. Nothing stops, for example, your default service handler from simply returning a 404 or your "Hello world" page, for example, if you don't want it to do anything else. As if it wouldn't be there. Yet it still serves the role of the default service.