mirror of https://github.com/perkeep/perkeep.git
Add discovery handler on root.
Change-Id: If816ff0dd5bb57d52445aff8cc67b8c801b606a8
This commit is contained in:
parent
de535fa264
commit
618efee2f5
|
@ -29,6 +29,8 @@ import (
|
||||||
type RootHandler struct {
|
type RootHandler struct {
|
||||||
// Don't advertise anything to non-authenticated clients.
|
// Don't advertise anything to non-authenticated clients.
|
||||||
Stealth bool
|
Stealth bool
|
||||||
|
|
||||||
|
ui *UIHandler // or nil, if none configured
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -42,10 +44,19 @@ func newRootFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handle
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, h, err := ld.FindHandlerByType("ui"); err == nil {
|
||||||
|
root.ui = h.(*UIHandler)
|
||||||
|
}
|
||||||
|
|
||||||
return root, nil
|
return root, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rh *RootHandler) ServeHTTP(conn http.ResponseWriter, req *http.Request) {
|
func (rh *RootHandler) ServeHTTP(conn http.ResponseWriter, req *http.Request) {
|
||||||
|
if rh.ui != nil && camliMode(req) == "config" && auth.IsAuthorized(req) {
|
||||||
|
rh.ui.serveDiscovery(conn, req)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if rh.Stealth {
|
if rh.Stealth {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue