以下是最终奏效的方法:
我修复了mkopriva指出的mux代码。(注意:http.handleFunc而不是http.Handle不起作用)。
我不得不将main()改为init(),然后应用引擎确认了我的mux设置。
因此,基本上我学到了go应用程序引擎本身无法处理多个处理程序的艰难方法,我在设置mux时搞砸了。
工作代码:
package sendmail
import (
"fmt"
_"github.com/sendgrid/sendgrid-go"
"net/http"
"google.golang.org/appengine"
"github.com/gorilla/mux"
"google.golang.org/appengine/log"
)
func init() {
r := mux.NewRouter()
r.HandleFunc("/send", sendhardcoded)
r.HandleFunc("/emptysuccess", emptysuccess)
//appengine.Main() // Starts the server to receive requests
http.Handle("/", r)
}
func emptysuccess(w http.ResponseWriter, r *http.Request) {
fmt.Println(w, "Hello Success")
}
func sendhardcoded(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
log.Infof(ctx, "Running Sendhardcoded")
}