mirror of
https://github.com/golang/go
synced 2024-11-18 13:24:39 -07:00
godoc/dl: provide JSON feed of releases
This addresses the build errors that caused a revert of the original PR golang/tools#21 Fixes golang/go#23746 GitHub-Last-Rev: 6606c0b63afb4f1043b2aa2dc640edda4cf9afe8 GitHub-Pull-Request: golang/tools#25 Change-Id: Ic5a7e3054d182dc2041d2966ca68960c3abd7620 Reviewed-on: https://go-review.googlesource.com/96178 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
f8f2f88271
commit
86e0f6745d
@ -48,15 +48,15 @@ func RegisterHandlers(mux *http.ServeMux) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type File struct {
|
type File struct {
|
||||||
Filename string
|
Filename string `json:"filename"`
|
||||||
OS string
|
OS string `json:"os"`
|
||||||
Arch string
|
Arch string `json:"arch"`
|
||||||
Version string
|
Version string `json:"-"`
|
||||||
Checksum string `datastore:",noindex"` // SHA1; deprecated
|
Checksum string `json:"-" datastore:",noindex"` // SHA1; deprecated
|
||||||
ChecksumSHA256 string `datastore:",noindex"`
|
ChecksumSHA256 string `json:"sha256" datastore:",noindex"`
|
||||||
Size int64 `datastore:",noindex"`
|
Size int64 `json:"size" datastore:",noindex"`
|
||||||
Kind string // "archive", "installer", "source"
|
Kind string `json:"kind"` // "archive", "installer", "source"
|
||||||
Uploaded time.Time
|
Uploaded time.Time `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f File) ChecksumType() string {
|
func (f File) ChecksumType() string {
|
||||||
@ -137,11 +137,11 @@ func (f File) URL() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Release struct {
|
type Release struct {
|
||||||
Version string
|
Version string `json:"version"`
|
||||||
Stable bool
|
Stable bool `json:"stable"`
|
||||||
Files []File
|
Files []File `json:"files"`
|
||||||
Visible bool // show files on page load
|
Visible bool `json:"-"` // show files on page load
|
||||||
SplitPortTable bool // whether files should be split by primary/other ports.
|
SplitPortTable bool `json:"-"` // whether files should be split by primary/other ports.
|
||||||
}
|
}
|
||||||
|
|
||||||
type Feature struct {
|
type Feature struct {
|
||||||
@ -221,6 +221,17 @@ func listHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Errorf(c, "cache set error: %v", err)
|
log.Errorf(c, "cache set error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.URL.Query().Get("mode") == "json" {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
enc := json.NewEncoder(w)
|
||||||
|
enc.SetIndent("", " ")
|
||||||
|
if err := enc.Encode(d.Stable); err != nil {
|
||||||
|
log.Errorf(c, "failed rendering JSON for releases: %v", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := listTemplate.ExecuteTemplate(w, "root", d); err != nil {
|
if err := listTemplate.ExecuteTemplate(w, "root", d); err != nil {
|
||||||
log.Errorf(c, "error executing template: %v", err)
|
log.Errorf(c, "error executing template: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user