From 618efee2f50206e31225a4d54c0a77b07f341a8e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 13 May 2012 12:16:59 -0700 Subject: [PATCH] Add discovery handler on root. Change-Id: If816ff0dd5bb57d52445aff8cc67b8c801b606a8 --- pkg/server/root.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/server/root.go b/pkg/server/root.go index 9f1382048..a1d7fa51c 100644 --- a/pkg/server/root.go +++ b/pkg/server/root.go @@ -29,6 +29,8 @@ import ( type RootHandler struct { // Don't advertise anything to non-authenticated clients. Stealth bool + + ui *UIHandler // or nil, if none configured } func init() { @@ -42,10 +44,19 @@ func newRootFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handle return } + if _, h, err := ld.FindHandlerByType("ui"); err == nil { + root.ui = h.(*UIHandler) + } + return root, nil } 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 { return }