You can use Gorilla Mux with the App Engine. Here's how:
At the end of the app.yaml handlers section, add a script handler that routes all paths to the Go application:
application: myapp version: 1 runtime: go api_version: go1 handlers: - url: /(.*\.(gif|png|jpg))$ static_files: static/\1 upload: static/.*\.(gif|png|jpg)$ - url: /.* script: _go_app
_go_app script is a Go program compiled by App Engine. The /.* pattern matches all paths.
The main function created by App Engine sends all DefaultServeMux requests.
In the init () function, create and configure a Gorilla Router . Register your Gorilla router with DefaultServeMux to handle all paths:
func init() { r := mux.NewRouter() r.HandleFunc("/", homeHandler) // The path "/" matches everything not matched by some other path. http.Handle("/", r) }
user4122236
source share