OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
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 "path" | |
22 "strings" | |
23 | |
24 "google.golang.org/appengine" | |
25 "google.golang.org/appengine/urlfetch" | |
26 ) | |
27 | |
28 const baseURL = "http://docs.crashpad.googlecode.com/git" | |
29 | |
30 func init() { | |
31 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
32 ctx := appengine.NewContext(r) | |
33 client := urlfetch.Client(ctx) | |
34 | |
35 // Don’t show dotfiles. | |
36 if strings.HasPrefix(path.Base(r.URL.Path), ".") { | |
37 http.Error(w, http.StatusText(http.StatusNotFound), http .StatusNotFound) | |
38 return | |
39 } | |
40 | |
41 if r.URL.Path == "/" { | |
42 http.Redirect(w, r, "/index.html", http.StatusFound) | |
43 return | |
44 } | |
45 | |
46 resp, err := client.Get(baseURL + r.URL.Path) | |
47 if err != nil { | |
48 http.Error(w, err.Error(), http.StatusInternalServerErro r) | |
49 return | |
50 } | |
51 defer resp.Body.Close() | |
52 w.Header().Set("Content-Type", resp.Header.Get("Content-Type")) | |
Mark Mentovai
2015/10/08 19:07:09
We have .html, .css, .js, and .png. Does this set
| |
53 io.Copy(w, resp.Body) | |
54 }) | |
55 } | |
OLD | NEW |