OLD | NEW |
---|---|
(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 } | |
OLD | NEW |