mirror of https://github.com/perkeep/perkeep.git
Merge "server status: bugfixes, and rid of version as a field."
This commit is contained in:
commit
277795ad46
|
@ -27,7 +27,6 @@ import (
|
||||||
|
|
||||||
// StatusHandler publishes server status information.
|
// StatusHandler publishes server status information.
|
||||||
type StatusHandler struct {
|
type StatusHandler struct {
|
||||||
Version string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -35,16 +34,14 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newStatusFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handler, err error) {
|
func newStatusFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handler, err error) {
|
||||||
sh := &StatusHandler{
|
return &StatusHandler{}, nil
|
||||||
Version: buildinfo.Version(),
|
|
||||||
}
|
|
||||||
return sh, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sh *StatusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (sh *StatusHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
suffix := req.Header.Get("X-PrefixHandler-PathSuffix")
|
suffix := req.Header.Get("X-PrefixHandler-PathSuffix")
|
||||||
if req.Method != "GET" {
|
if req.Method != "GET" {
|
||||||
http.Error(rw, "Illegal URL.", 404)
|
http.Error(rw, "Illegal URL.", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if suffix == "status.json" {
|
if suffix == "status.json" {
|
||||||
sh.serveStatus(rw, req)
|
sh.serveStatus(rw, req)
|
||||||
|
@ -59,7 +56,7 @@ type statusResponse struct {
|
||||||
|
|
||||||
func (sh *StatusHandler) serveStatus(rw http.ResponseWriter, req *http.Request) {
|
func (sh *StatusHandler) serveStatus(rw http.ResponseWriter, req *http.Request) {
|
||||||
res := &statusResponse{
|
res := &statusResponse{
|
||||||
Version: sh.Version,
|
Version: buildinfo.Version(),
|
||||||
}
|
}
|
||||||
|
|
||||||
httputil.ReturnJSON(rw, res)
|
httputil.ReturnJSON(rw, res)
|
||||||
|
|
|
@ -9,4 +9,5 @@
|
||||||
.cam-index-serverinfo {
|
.cam-index-serverinfo {
|
||||||
display: inline;
|
display: inline;
|
||||||
float: right;
|
float: right;
|
||||||
|
font-size: small;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue