Chromium Code Reviews| Index: doc/appengine/main.go |
| diff --git a/doc/appengine/main.go b/doc/appengine/main.go |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..3e1877231a990dd511a3276800749e0beb0e1d5a |
| --- /dev/null |
| +++ b/doc/appengine/main.go |
| @@ -0,0 +1,55 @@ |
| +// Copyright 2015 The Crashpad Authors. All rights reserved. |
| +// |
| +// 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" |
| + "path" |
| + "strings" |
| + |
| + "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) |
| + |
| + // Don’t show dotfiles. |
| + if strings.HasPrefix(path.Base(r.URL.Path), ".") { |
| + http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) |
| + return |
| + } |
| + |
| + if r.URL.Path == "/" { |
| + http.Redirect(w, r, "/index.html", http.StatusFound) |
| + return |
| + } |
| + |
| + resp, err := client.Get(baseURL + r.URL.Path) |
| + 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")) |
|
Mark Mentovai
2015/10/08 19:07:09
We have .html, .css, .js, and .png. Does this set
|
| + io.Copy(w, resp.Body) |
| + }) |
| +} |