aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2012-03-20 14:11:38 +1100
committerAndrew Gerrand <adg@golang.org>2012-03-20 14:11:38 +1100
commitabdb4dbe2c9c3315f23f68b784fd995e3c5705f7 (patch)
tree92befe1bd1a53fb38595e71dc1228972c2509c28
parent58aac1d0ffe9e1c00347626306c30caa5dfb44e3 (diff)
downloadgo-abdb4dbe2c9c3315f23f68b784fd995e3c5705f7.tar.gz
go-abdb4dbe2c9c3315f23f68b784fd995e3c5705f7.zip
cmd/godoc: inform users that the playground doesn't work via local godoc
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5843065
-rw-r--r--doc/play/playground.js15
-rw-r--r--src/cmd/godoc/main.go10
2 files changed, 21 insertions, 4 deletions
diff --git a/doc/play/playground.js b/doc/play/playground.js
index 69dc451fc1..947f8a4ece 100644
--- a/doc/play/playground.js
+++ b/doc/play/playground.js
@@ -166,10 +166,13 @@ function playground(opts) {
}
pre.text(out);
},
- error: function() {
- output.addClass("error").text(
- "Error communicating with remote server."
- );
+ error: function(xhr) {
+ var text = "Error communicating with remote server.";
+ console.log(xhr.status);
+ if (xhr.status == 501) {
+ text = xhr.responseText;
+ }
+ output.addClass("error").text(text);
}
});
}
@@ -190,6 +193,10 @@ function playground(opts) {
type: "POST",
complete: function(xhr) {
sharing = false;
+ if (xhr.status == 501) {
+ alert(xhr.responseText);
+ return;
+ }
if (xhr.status != 200) {
alert("Server error; try again.");
return;
diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go
index 96f6ebe9d6..10a14b9a8b 100644
--- a/src/cmd/godoc/main.go
+++ b/src/cmd/godoc/main.go
@@ -274,6 +274,10 @@ func main() {
registerPublicHandlers(http.DefaultServeMux)
+ // Playground handlers are not available in local godoc.
+ http.HandleFunc("/compile", disabledHandler)
+ http.HandleFunc("/share", disabledHandler)
+
// Initialize default directory tree with corresponding timestamp.
// (Do it in a goroutine so that launch is quick.)
go initFSTree()
@@ -450,3 +454,9 @@ type httpWriter struct {
func (w *httpWriter) Header() http.Header { return w.h }
func (w *httpWriter) WriteHeader(code int) { w.code = code }
+
+// disabledHandler serves a 501 "Not Implemented" response.
+func disabledHandler(w http.ResponseWriter, r *http.Request) {
+ w.WriteHeader(http.StatusNotImplemented)
+ fmt.Fprint(w, "This functionality is not available via local godoc.")
+}