@@ -27,11 +27,10 @@ import ( "dmitri.shuralyov.com/changes/gerritapi" "dmitri.shuralyov.com/changes/githubapi" "dmitri.shuralyov.com/changes/maintner" "github.com/andygrunwald/go-gerrit" "github.com/google/go-github/github" "github.com/gorilla/mux" "github.com/gregjones/httpcache" "github.com/shurcooL/githubql" "github.com/shurcooL/httpgzip" "github.com/shurcooL/reactions/emojis" ghusers "github.com/shurcooL/users/githubapi" @@ -104,12 +103,10 @@ func main() { </style>`, DisableReactions: true, } changesApp := changesapp.New(service, nil, changesOpt) r := mux.NewRouter() issuesHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { prefixLen := len("/changes") if prefix := req.URL.Path[:prefixLen]; req.URL.Path == prefix+"/" { baseURL := prefix if req.URL.RawQuery != "" { @@ -125,23 +122,23 @@ func main() { //req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "go.googlesource.com/go")) req = req.WithContext(context.WithValue(req.Context(), changesapp.RepoSpecContextKey, "github.com/google/go-github")) req = req.WithContext(context.WithValue(req.Context(), changesapp.BaseURIContextKey, "/changes")) changesApp.ServeHTTP(w, req) }) r.Path("/changes").Handler(issuesHandler) r.PathPrefix("/changes/").Handler(issuesHandler) http.Handle("/changes", issuesHandler) http.Handle("/changes/", issuesHandler) r.HandleFunc("/login/github", func(w http.ResponseWriter, req *http.Request) { http.HandleFunc("/login/github", func(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "text/plain") fmt.Fprintln(w, "Sorry, this is just a demo instance and it doesn't support signing in.") }) emojisHandler := httpgzip.FileServer(emojis.Assets, httpgzip.FileServerOptions{ServeError: httpgzip.Detailed}) r.PathPrefix("/emojis/").Handler(http.StripPrefix("/emojis", emojisHandler)) http.Handle("/emojis/", http.StripPrefix("/emojis", emojisHandler)) printServingAt(*httpFlag) err := http.ListenAndServe(*httpFlag, r) err := http.ListenAndServe(*httpFlag, nil) if err != nil { log.Fatalln("ListenAndServe:", err) } }