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

Side by Side 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 unified diff | Download patch
« docs-appengine/app.yaml ('K') | « docs-appengine/app.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Package crashpad mirrors crashpad documentation from Chromium’s git repo.
16 package crashpad
17
18 import (
19 "io"
20 "net/http"
21
22 "google.golang.org/appengine"
23 "google.golang.org/appengine/urlfetch"
24 )
25
26 const baseURL = "http://docs.crashpad.googlecode.com/git"
27
28 func init() {
29 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
30 ctx := appengine.NewContext(r)
31 client := urlfetch.Client(ctx)
32
33 if r.URL.Path == "/" {
34 http.Redirect(w, r, "/doc/index.html", http.StatusSeeOth er)
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.
35 return
36 }
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
37
38 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 ¯\_
39 if err != nil {
40 http.Error(w, err.Error(), http.StatusInternalServerErro r)
41 return
42 }
43 defer resp.Body.Close()
44 w.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
45 io.Copy(w, resp.Body)
46 })
47 }
OLDNEW
« 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