google-app-engine


Google App Engine Custom Domain - Routing in Go


I've been utilizing the url provided to me by the google-app-engine, i.e. "projectname-id.appspot.com" for my project. I had previously purchased a custom domain from GoDaddy, and I followed the steps at the following link to verify ownership of the domain name within the Google Cloud Platform, add the domain to my Google App Engine Project, and update my DNS settings in GoDaddy to point to the listed CNAME/server combination. https://cloud.google.com/appengine/docs/go/console/using-custom-domains-and-ssl
When I visit my custom domain, a website page is served, but it's always a 404. The "projectname-id.appspot.com" url still works correctly, and when I look at the log statements in the Google App Engine, it receives the request from both my custom domain and the appspot domain - which seems to suggest the domain dns was updated properly. See image below, where the 404 is from the custom domain and the 200 is from the appspot url:
Google App Engine Logs
Is there anything else I have to do? The backend is written in Go, and we're using the Mux Router. Do I need to modifiy my app.yaml file or edit my routes somehow? Any suggestions would be greatly appreciated.
Here I've included some code snippets I use to initialize my server:
App.yaml
version: alpha-001
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
env_variables:
PRODUCTION: 'TRUE'
DATASTORE_DATASET: 'app-id'
DATASTORE_HOST: 'http://localhost:8043'
DATASTORE_EMULATOR_HOST: 'localhost:8043'
DATASTORE_PROJECT_ID: 'app-id'
GOOGLE_APPLICATION_CREDENTIALS: './app-string.json'
Initializing the WebConsole (Server):
func init() {
// Web Server for API Endpoints
flag.Parse()
var server *web_console.WebConsole
if prod := os.Getenv("PRODUCTION"); prod == "FALSE" {
server = web_console.NewWebConsole(false)
} else {
server = web_console.NewWebConsole(true)
}
server.Run()
}
WebConsole.go
type WebConsole struct {
prod bool
Mux *mux.Router
DbMap *gorp.DbMap
Client *datastore.Client
}
func NewWebConsole(prod bool) *WebConsole {
return &WebConsole{
prod: prod,
}
}
func (w *WebConsole) Run() {
w.dbInit()
w.routesInit()
}
func (w *WebConsole) dbInit() {
// Configure SQL connection
// Code removed for privacy reasons
}
func (w *WebConsole) routesInit() {
// Configure routes with Mux
w.Mux = mux.NewRouter()
api.AddCertChallengeApis(w.Mux)
// The path "/" matches everything not matched by some other path.
// Checkout: http://stackoverflow.com/questions/26581231/google-cloud-go-handler-without-router-gorilla-mux
// for more details
http.Handle("/", w.Mux)
}
Api Package File for Routing
package api
import (
"github.com/gorilla/mux"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"net/http"
"strings"
)
func AddCertChallengeApis(r *mux.Router) {
r.Schemes("http")
r.HandleFunc("/", defaultHandler())
}
func defaultHandler() http.HandlerFunc {
return func(rw http.ResponseWriter, req *http.Request) {
// Construct new app engine context
c := appengine.NewContext(req)
log.Infof(c, "App ID: %v", appengine.AppID(c))
rw.Header().Set("Content-Type", "text/plain")
rw.Write([]byte("hi, welcome to my website yo"))
log.Infof(c, "Hit the website")
}
}
I have done custom domains on appengine/go before, and there is nothing else you should have to do. I would try removing this line, though,
r.Schemes("http")
in case it is something https related.

Related Links

Datastore Callbacks and App Engine Modules in Java
App Engine can't find static files
Access app-id.appspot.com through CDN
Dynamically adding fields to WTForms returning UnboundField
1.8.5 Prelease Accidentally in Production
Trying to get an SSL certificate from Comodo to work for Google App Engine
Login loop when adding a custom domain for appengine
InvalidClassException: No valid constructor
CookieJar does not catch incoming cookies
Google Cloud Console Projects, Advantage To Have Different Elements Under Same Project?
No api proxy found for service “datastore_v4” in new GAE 1.8.4
Which Google App Engine installer do I want to use for Windows?
Using Access Token from google cloud to login to Gmail
GAE : Yahoo, Google & Facebook login support
Google App Engine : JDO deletePersistent not consistent
Objectify 4 throwing strange error in GAE

Categories

HOME
service-worker
asp.net-web-api
oracle12c
porting
prism
datastore
themes
yahoo-finance
camera
error-handling
rendering
carousel
nsbundle
parameters
web-hosting
gembox-spreadsheet
onclick
hpc
32bit-64bit
reactive-programming
onedrive-api
video-editing
html5-appcache
foreign-keys
cfml
solrcloud
dpdk
parcelable
qliksense
zxing
draft-js-plugins
pylons
jasmine-node
intersystems-cache
user-defined-functions
iis-express
zend-debugger
kodi
clickjacking
card.io
hreflang
baidu-map
servicestack-text
reason
parse-tree
protein-database
filesystemwatcher
ogc
trigonometry
datacachefactory
linqpad
bindingnavigator
mesosphere
jboss-4.2.x
yii2-api
reindex
amq
scalding
video-conferencing
spring-data-couchbase
colorbar
cd-burning
mapxtreme
uicolor
mongodb-php
simevents
deep
fink
grgit
morton-number
include-guards
rubaxa-sortable
nutiteq
phpldapadmin
android-vibration
ssis-data-flow
metatrader5
rickshaw
lambda-architecture
terminate
synapse
windows-embedded-standard
high-resolution
breakout
flex++
mantle
apache-abdera
android-sdk-2.3
booksleeve
android-loadermanager
onmousemove
multiplexing
azman
jqote
silent
eclipse-marketplace
application-verifier
pagemethods

Resources

Encrypt Message