Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(240)

Side by Side Diff: src/cmd/godoc/appinit.go

Issue 12206044: code review 12206044: cmd/godoc: delete from core repository (Closed)
Patch Set: diff -r a2e6a2fddcf5 https://code.google.com/p/go Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/godoc/README.godoc-app ('k') | src/cmd/godoc/codewalk.go » ('j') | 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 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build appengine
6
7 package main
8
9 // This file replaces main.go when running godoc under app-engine.
10 // See README.godoc-app for details.
11
12 import (
13 "archive/zip"
14 "log"
15 "net/http"
16 "path"
17 )
18
19 func serveError(w http.ResponseWriter, r *http.Request, relpath string, err erro r) {
20 w.WriteHeader(http.StatusNotFound)
21 servePage(w, Page{
22 Title: "File " + relpath,
23 Subtitle: relpath,
24 Body: applyTemplate(errorHTML, "errorHTML", err), // err may contain an absolute path!
25 })
26 }
27
28 func init() {
29 log.Println("initializing godoc ...")
30 log.Printf(".zip file = %s", zipFilename)
31 log.Printf(".zip GOROOT = %s", zipGoroot)
32 log.Printf("index files = %s", indexFilenames)
33
34 // initialize flags for app engine
35 *goroot = path.Join("/", zipGoroot) // fsHttp paths are relative to '/'
36 *indexEnabled = true
37 *indexFiles = indexFilenames
38 *maxResults = 100 // reduce latency by limiting the number of fulltex t search results
39 *indexThrottle = 0.3 // in case *indexFiles is empty (and thus the index er is run)
40 *showPlayground = true
41
42 // read .zip file and set up file systems
43 const zipfile = zipFilename
44 rc, err := zip.OpenReader(zipfile)
45 if err != nil {
46 log.Fatalf("%s: %s\n", zipfile, err)
47 }
48 // rc is never closed (app running forever)
49 fs.Bind("/", NewZipFS(rc, zipFilename), *goroot, bindReplace)
50
51 // initialize http handlers
52 readTemplates()
53 initHandlers()
54 registerPublicHandlers(http.DefaultServeMux)
55 registerPlaygroundHandlers(http.DefaultServeMux)
56
57 // initialize default directory tree with corresponding timestamp.
58 initFSTree()
59
60 // Immediately update metadata.
61 updateMetadata()
62
63 // initialize search index
64 if *indexEnabled {
65 go indexer()
66 }
67
68 log.Println("godoc initialization complete")
69 }
OLDNEW
« no previous file with comments | « src/cmd/godoc/README.godoc-app ('k') | src/cmd/godoc/codewalk.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b