mirror of
https://github.com/golang/go
synced 2024-11-18 10:54:40 -07:00
godoc/static: let client use vet check returned by /compile endpoint
(Forked off Yury Smolsky's CL 176618) With this change, the playground.js client now asks the server to do a vet check in the same HTTP request as the /compile (and run) step. If the server replies that it understands the request (VetErrors or VetOK in the repsonse), then the client can avoid the latency of a second HTTP roundtrip. We'll remove the /vet handler after we see it fall out of use from older clients. Updates golang/go#31970 Change-Id: I5b123883e19cbc6a8ec30c50705e6b945a4d322d Reviewed-on: https://go-review.googlesource.com/c/tools/+/176939 Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
parent
d81a07b7e5
commit
2a413a02cc
@ -117,7 +117,7 @@ function HTTPTransport(enableVet) {
|
||||
var playing;
|
||||
$.ajax('/compile', {
|
||||
type: 'POST',
|
||||
data: {'version': 2, 'body': body},
|
||||
data: {'version': 2, 'body': body, 'withVet': enableVet},
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
if (seq != cur) return;
|
||||
@ -132,21 +132,31 @@ function HTTPTransport(enableVet) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!data.Events) {
|
||||
data.Events = [];
|
||||
}
|
||||
if (data.VetErrors) {
|
||||
// Inject errors from the vet as the first events in the output.
|
||||
data.Events.unshift({Message: 'Go vet exited.\n\n', Kind: 'system', Delay: 0});
|
||||
data.Events.unshift({Message: data.VetErrors, Kind: 'stderr', Delay: 0});
|
||||
}
|
||||
|
||||
if (!enableVet) {
|
||||
if (!enableVet || data.VetOK || data.VetErrors) {
|
||||
playing = playback(output, data);
|
||||
return;
|
||||
}
|
||||
|
||||
// In case the server support doesn't support
|
||||
// compile+vet in same request signaled by the
|
||||
// 'withVet' parameter above, also try the old way.
|
||||
// TODO: remove this when it falls out of use.
|
||||
// It is 2019-05-13 now.
|
||||
$.ajax("/vet", {
|
||||
data: {"body": body},
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
success: function(dataVet) {
|
||||
if (dataVet.Errors) {
|
||||
if (!data.Events) {
|
||||
data.Events = [];
|
||||
}
|
||||
// inject errors from the vet as the first events in the output
|
||||
data.Events.unshift({Message: 'Go vet exited.\n\n', Kind: 'system', Delay: 0});
|
||||
data.Events.unshift({Message: dataVet.Errors, Kind: 'stderr', Delay: 0});
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user