mirror of
https://github.com/golang/go
synced 2024-11-23 23:40:13 -07:00
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
This commit is contained in:
parent
58aac1d0ff
commit
abdb4dbe2c
@ -166,10 +166,13 @@ function playground(opts) {
|
|||||||
}
|
}
|
||||||
pre.text(out);
|
pre.text(out);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function(xhr) {
|
||||||
output.addClass("error").text(
|
var text = "Error communicating with remote server.";
|
||||||
"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",
|
type: "POST",
|
||||||
complete: function(xhr) {
|
complete: function(xhr) {
|
||||||
sharing = false;
|
sharing = false;
|
||||||
|
if (xhr.status == 501) {
|
||||||
|
alert(xhr.responseText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (xhr.status != 200) {
|
if (xhr.status != 200) {
|
||||||
alert("Server error; try again.");
|
alert("Server error; try again.");
|
||||||
return;
|
return;
|
||||||
|
@ -274,6 +274,10 @@ func main() {
|
|||||||
|
|
||||||
registerPublicHandlers(http.DefaultServeMux)
|
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.
|
// Initialize default directory tree with corresponding timestamp.
|
||||||
// (Do it in a goroutine so that launch is quick.)
|
// (Do it in a goroutine so that launch is quick.)
|
||||||
go initFSTree()
|
go initFSTree()
|
||||||
@ -450,3 +454,9 @@ type httpWriter struct {
|
|||||||
|
|
||||||
func (w *httpWriter) Header() http.Header { return w.h }
|
func (w *httpWriter) Header() http.Header { return w.h }
|
||||||
func (w *httpWriter) WriteHeader(code int) { w.code = code }
|
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.")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user