Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Unified Diff: docs-appengine/main.go

Issue 1393353002: Add app engine app to mirror html docs from chromium.googlesource.com (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« docs-appengine/app.yaml ('K') | « docs-appengine/app.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: docs-appengine/main.go
diff --git a/docs-appengine/main.go b/docs-appengine/main.go
new file mode 100755
index 0000000000000000000000000000000000000000..adc0e14cfd77664a3add905daa7f3dfbc7ebe067
--- /dev/null
+++ b/docs-appengine/main.go
@@ -0,0 +1,47 @@
+// Copyright 2015 The Crashpad Authors. All rights reserved.
Mark Mentovai 2015/10/08 18:28:03 Ought to be in doc/appengine
Bons 2015/10/08 18:55:17 Done.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package crashpad mirrors crashpad documentation from Chromium’s git repo.
+package crashpad
+
+import (
+ "io"
+ "net/http"
+
+ "google.golang.org/appengine"
+ "google.golang.org/appengine/urlfetch"
+)
+
+const baseURL = "http://docs.crashpad.googlecode.com/git"
+
+func init() {
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ ctx := appengine.NewContext(r)
+ client := urlfetch.Client(ctx)
+
+ if r.URL.Path == "/" {
+ http.Redirect(w, r, "/doc/index.html", http.StatusSeeOther)
Robert Sesek 2015/10/08 18:27:27 303 is typically used in response to a POST reques
Mark Mentovai 2015/10/08 18:28:03 This one will become just index.html.
Bons 2015/10/08 18:55:17 Will update once we have the repo url
Bons 2015/10/08 18:55:17 Done.
+ return
+ }
Mark Mentovai 2015/10/08 18:28:03 /man or /man/ or both should become /man/index.htm
Bons 2015/10/08 18:55:17 ditto when we can test on the real repo url
+
+ resp, err := client.Get(baseURL + r.URL.Path)
Robert Sesek 2015/10/08 18:27:27 Prevent path traversal in Path.
Bons 2015/10/08 18:55:17 app engine seems to be doing this already? o_O ¯\_
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ defer resp.Body.Close()
+ w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
+ io.Copy(w, resp.Body)
+ })
+}
« docs-appengine/app.yaml ('K') | « docs-appengine/app.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698